Ciao, (solo) oggi mi sono imbattuto in "0 in (False,)" che ha un comportamento francamente controintuitivo:
In [1]: 0 in (False,) Out[1]: True che a sua volta dipende dal fatto che: In [2]: 0 == False Out[2]: True Sono quindi andato a rispulciarmi la language reference:: The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily. Objects of different type always compare unequal: In [3]: type(0) Out[3]: <type 'int'> In [4]: type(False) Out[4]: <type 'bool'> 0 e False *sono* tipi differenti ... ah no! In [6]: isinstance(False, int) Out[6]: True In [7]: bool.__mro__ Out[7]: (<type 'bool'>, <type 'int'>, <type 'object'>) Mi viene qui di da chiedermi: ma che bisogno c'รจ che un booleano erediti da un intero? piace a tutti che "0 == False" sia vero? sandro *:-) -- Sandro Dentella *:-) http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python