finding name of instances created
André
andre.roberge at gmail.com
Fri Jan 21 19:13:19 EST 2005
Short version of what I am looking for:
Given a class "public_class" which is instantiated a few times e.g.
a = public_class()
b = public_class()
c = public_class()
I would like to find out the name of the instances so that I could
create a list of them e.g.
['a', 'b', 'c']
I've read the Python Cookbook, Python in a Nutshell, Programming
Python, Learning Python, ... googled (probably missed something
obvious), all to no avail.
=====
Longer version:
If I can do the above, I believe I could do the following thing which
is what I am really after eventually.
Given the statement
>> a = public_class()
I would like to generate
>> my_dict['a'] = private_class()
so that one could write
>> a.apparently_simple_method()
and that, behind the scene, I could translate that as
>> my_dict['a'].not_so_simple_method()
as well as do things like
>> for name in my_dict:
>> do_stuff(name)
Any help, pointers, sketches or outline of solution would be greatly
appreciated.
André
More information about the Python-list
mailing list