Probably a stupid question... name-->method lookup

Andrew Dalke dalke at
Wed Aug 22 17:19:42 CEST 2001

Joseph Andrew Knapka:
>I have a method name (string) and a class object. I'd like to
>be able to look up the the named unbound method of the class.

>>> class Spam:
...  def eggs(self):
...   return 1
>>> umeth = getattr(Spam, "eggs")
>>> spam = Spam()
>>> umeth(spam)


More information about the Python-list mailing list