[Tutor] getattr()
Alan Gauld
alan.gauld at freenet.co.uk
Wed Jul 26 21:08:13 CEST 2006
Janos,
I'm confused...
#################
#This should be the complete file
def OnMenuFindMe():
print 'You found me'
f = getattr(What_Should_It_Be???, 'OnMenuFindMe')
f()
#################
You are trying to get a reference to a function in the same
file and whose name you know? So why not just
f = OnMenuFindMe
f()
Or just call the function!
getattr makes sense when its another module or a class
where you may not have access to the function somehow
but it doesn't make much sense in this case - at least
not to me!
Alan G.
More information about the Tutor
mailing list