>
> 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.
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a