Classes & Instances

Terry Reedy tjreedy at home.com
Wed Jan 2 15:50:57 EST 2002


> Now, for the problem. How do I get a class, so that when an instance
> is made of it, the class records the instance's name to a list.

Python objects do not have 'a name'.  Rather, 0 to n names can be
bound to any object.  Functions, classes, and modules have
definition_names which may or may not correspond to any names
currently bound to the object.  As others have pointed out, if you
want instances to also have a definition name, you will have to pass
in into __init__ and set it explicitly.

Terry J. Reedy






More information about the Python-list mailing list