Classes and modules are singletons?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 7 00:17:49 CET 2008


En Thu, 06 Mar 2008 20:45:09 -0200, <castironpi at gmail.com> escribi�:

> I'd like to question the source of the definition of C.__eq__.
>
> Observation:
>
>>>> class C: pass
> ...
>>>> class D: pass
> ...
>>>> C== D
> False
>
> What is different about them?  I've created two empty classes, nothing
> more.

Their __name__ attribute?
Types are compared by their memory addresses, not by contents, and that's  
enough and efficient for most people. If you require something different,  
use a metaclass.

-- 
Gabriel Genellina




More information about the Python-list mailing list