<div dir="ltr">Trošku z jiného soudku:<div><br></div><div><div>$ python3</div><div>Python 3.4.3 (default, Mar 23 2015, 04:19:36)</div><div>[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin</div><div>Type "help", "copyright", "credits" or "license" for more information.</div><div>>>></div><div>>>> class Account:</div><div>... def deposit(self, amount):</div><div>... print('saved:', amount)</div><div>...</div><div>>>> class SecureAccount(Account):</div><div>... def safe_deposit(self, amount):</div><div>... print('*secure transaction begin*')</div><div>... super().deposit(amount)</div><div>... print('*secure transaction end*')</div><div>...</div><div>>>> sa = SecureAccount()</div><div>>>> sa.safe_deposit(100)</div><div>*secure transaction begin*</div><div>saved: 100</div><div>*secure transaction end*</div><div>>>></div><div>>>> class Thief(Account):</div><div>... def deposit(self, amount):</div><div>... print('STOLEN:', amount)</div><div>...</div><div>>>> class MyAccount(SecureAccount, Thief):</div><div>... pass</div><div>...</div><div>>>> ma = MyAccount()</div><div>>>> ma.safe_deposit(200)</div><div>*secure transaction begin*</div><div>STOLEN: 200</div><div>*secure transaction end*</div><div>>>></div></div><div><br></div><div>Honza</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-05-11 23:57 GMT+02:00 Matěj Cepl <span dir="ltr"><<a href="mailto:mcepl@cepl.eu" target="_blank">mcepl@cepl.eu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2015-05-11, 20:53 GMT, Honza Král wrote:<br>
> Jen pozor, ze tohle je chovani CPythonu, tedy jedne z implementaci a<br>
> nikoli definice chovani pythonu, nelze tedy na to spolehat a<br>
> porovnavani integereru by se melo vzdy provadet pres == a nikdy pres<br>
> is, i kdybychom meli 1000% jistotu, ze to budou jen cisla od 0 do 10.<br>
> Honza Král<br>
<br>
</span>Skutečně, neni Python jako Python:<br>
<br>
$ jython<br>
Jython 2.7b4 (default:3672e624962a, Feb 13 2015, 04:59:14)<br>
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.7.0_79<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
<span class=""> >>> a = 256<br>
>>> b = 256<br>
>>> a is b<br>
True<br>
>>> a = 257<br>
>>> b = 257<br>
>>> a is b<br>
</span> True<br>
>>><br>
$<br>
<br>
Zajímavě,<br>
<br>
Matěj<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="http://www.ceplovi.cz/matej/" target="_blank">http://www.ceplovi.cz/matej/</a>, Jabber: mcepl<at><a href="http://ceplovi.cz" target="_blank">ceplovi.cz</a><br>
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC<br>
<br>
The ratio of literacy to illiteracy is a constant, but nowadays<br>
the illiterates can read.<br>
-- Alberto Moravia<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Python mailing list<br>
<a href="mailto:python@py.cz">python@py.cz</a><br>
<a href="http://www.py.cz/mailman/listinfo/python" target="_blank">http://www.py.cz/mailman/listinfo/python</a><br>
<br>
Visit: <a href="http://www.py.cz" target="_blank">http://www.py.cz</a><br>
</div></div></blockquote></div><br></div>