[Tutor] getattr()

János Juhász janos.juhasz at VELUX.com
Wed Jul 26 15:37:23 CEST 2006


Dear Kent,

>>You can look up the function in the globals() dict, or you can import 
>>__main__, which is the top-level module, and use getattr() on it. Or you 

>>could wrap your functions in a class...
>>
>>def OnMenuFindMe():
>>    print 'You found me'
>>
>>f = globals()['OnMenuFindMe']
>>
>>f()
>>
>>import __main__
>>
>>g = getattr(__main__, 'OnMenuFindMe')
>>g()
>>
>>Kent

Many thanks.


Yours sincerely, 
______________________________
János Juhász 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060726/0c632b17/attachment.htm 


More information about the Tutor mailing list