On 12/27/2012 03:26 AM, Abhas Bhattacharya wrote:
On Thursday, 27 December 2012 13:33:34 UTC+5:30, Mitya Sirenef  wrote:
How about defining a function that prints value and then calls a function?



def call(func_name):

    print(mydict[func_name])

    globals()[func_name]()





You could also define a custom class that does the same thing on attribute

lookup and do something like Call.func_name() .



   -m



--

Lark's Tongue Guide to Python: http://lightbird.net/larks/
Can you explain me what this means?
globals()[func_name]()

globals() is a globals dictionary that maps function
names to function objects (along with other things),
so we get the function object by name and then
run it.

 -m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to