Python class strangeitude

Terry Reedy tjreedy at
Sun Aug 25 08:48:59 CEST 2002

"Mr. Neutron" <nicktsocanos at> wrote in message
news:pan.2002. at
> Hi,
> I have discovered a strange thing about Python. I have a class,
> call it MyClass. MyClass is derived from MyClassBase.
> Now I do this
> Jimmy = MyClass(...)
> ...
> Randy = MyClass(...)
> And guess what? Jimmy and Randy are the same darn thing in memory! I
> assuming that classes in Python were like in C++ in the way they

If you write a class as a singleton class, this is the normal and
usually desired behavior.  Hard to do by accident though....


More information about the Python-list mailing list