Classes and modules are singletons?

castironpi at castironpi at
Thu Mar 6 23:45:09 CET 2008

On Mar 6, 3:24 pm, a... at (Aahz) wrote:
> In article <13sulsu4nbr2... at>,
> Steven D'Aprano  <st... at> wrote:
> >I accept my question about classes being singletons is not well-formed,
> >not even in my own mind. I guess one way of asking is, for any two class
> >objects (not instances) C1 and C2, does "C1 == C2" imply "C1 is C2"?
> Even that stricture fails under the presence of metaclasses.  ;-)  But
> answering your real question, I don't remember off-hand the required
> sequence, but it is possible to import a class two different ways such
> that the classes are not the object.  This can cause problems with e.g.
> pickle.  Within a single module, given a class defined only once within
> that module, the class will be a singleton.
> --
> Aahz (a... at           <*>
> "All problems in computer science can be solved by another level of    
> indirection."  --Butler Lampson

I'd like to question the source of the definition of C.__eq__.


>>> class C: pass
>>> class D: pass
>>> C== D

What is different about them?  I've created two empty classes, nothing

More information about the Python-list mailing list