Classes and modules are singletons?
castironpi at gmail.com
castironpi at gmail.com
Thu Mar 6 17:45:09 EST 2008
On Mar 6, 3:24 pm, a... at pythoncraft.com (Aahz) wrote:
> In article <13sulsu4nbr2... at corp.supernews.com>,
> Steven D'Aprano <st... at REMOVE-THIS-cybersource.com.au> 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 pythoncraft.com) <*> http://www.pythoncraft.com/
>
> "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__.
Observation:
>>> class C: pass
...
>>> class D: pass
...
>>> C== D
False
What is different about them? I've created two empty classes, nothing
more.
More information about the Python-list
mailing list