dictionary with object's method as thier items

noro amit.man at gmail.com
Wed Aug 30 09:35:17 EDT 2006


Is it possible to do the following:

for a certain class:

----------------------------
class C:

    def func1(self):
         pass
    def func2(self):
         pass
    def func4(self):
         pass

obj=C()
----------------------------

by some way create a dictionary that look somthing like that:

d= {'function one': <reference to C.func1()>, \
      'function two': <reference to C.func2()>, \
      'function three': <reference to C.func3()>}

and so i could access every method of instances of C, such as obj with
sometiing like:
(i know that this syntax wont work )

obj.(d['function one'])
obj.(d['function two'])
etc..


thanks




More information about the Python-list mailing list