Naming class instances in real time

Neil MacMillan neil at maxwell.bc.ca
Mon Aug 12 08:37:16 EDT 2002


Is there a clean way for me to name class instances (or variables, or 
whathaveyou without hard-coding the names?

For example, if I wanted to make objects representing people:

>>>class People():
...  pass
...

Can I then have a limited but unknown number of instances of 
that class in a running program named:

>>>person0 = People()
>>>person1 = People()
>>>person2 = People()

...and so on until the number of instances of People() is equal
to any randomly generated integer, and each instance is named
"person"+integer?

Thanks for any help you can give me, or, even better, any related documents
to which you can refer me (and I can find!).

Neil M.



More information about the Python-list mailing list