Finding the name of a function while defining it

Abhas Bhattacharya abhasbhattacharya2 at gmail.com
Thu Dec 27 03:26:57 EST 2012


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]()



More information about the Python-list mailing list