Short version of what I am looking for:
Given a class "public_cla ss" 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
[color=blue][color=green]
>> a = public_class()[/color][/color]
I would like to generate
[color=blue][color=green]
>> my_dict['a'] = private_class()[/color][/color]
so that one could write
[color=blue][color=green]
>> a.apparently_si mple_method()[/color][/color]
and that, behind the scene, I could translate that as
[color=blue][color=green]
>> my_dict['a'].not_so_simple_ method()[/color][/color]
as well as do things like
[color=blue][color=green]
>> for name in my_dict:
>> do_stuff(name)[/color][/color]
Any help, pointers, sketches or outline of solution would be greatly
appreciated.
André
Given a class "public_cla ss" 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
[color=blue][color=green]
>> a = public_class()[/color][/color]
I would like to generate
[color=blue][color=green]
>> my_dict['a'] = private_class()[/color][/color]
so that one could write
[color=blue][color=green]
>> a.apparently_si mple_method()[/color][/color]
and that, behind the scene, I could translate that as
[color=blue][color=green]
>> my_dict['a'].not_so_simple_ method()[/color][/color]
as well as do things like
[color=blue][color=green]
>> for name in my_dict:
>> do_stuff(name)[/color][/color]
Any help, pointers, sketches or outline of solution would be greatly
appreciated.
André
Comment