[Python] Python vs Java

Simone Federici s.federici a gmail.com
Ven 2 Gen 2015 15:41:13 CET


>
> Enrico Bianchi:
>
>> Per curiosita`, perche` e` visto come un antipattern? Mi va bene anche un
>> po' di letteratura
>
>
Me:
>
> >>> class X(int): pass
> >>> type(X()) == int
> False
> >>> isinstance(X(), int)
> True
>
> vedi: Liskov Substitution Principle
>

Cmq Scott Meyers in Effective C++ scriveva:

"Anytime you find yourself writing code of the form "if the object is of
type T1, then do something, but if it's of type T2, then do something
else," slap yourself.

Il che mi sembra abbastanza esplicativo, visto che abbiamo l'OOP: basta
fare una inversione.
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20150102/4e4fc2dc/attachment.html>


Maggiori informazioni sulla lista Python