Get bound method by name
clp2 at rebertia.com
Tue Mar 3 12:18:42 CET 2009
On Tue, Mar 3, 2009 at 3:12 AM, Johannes Bauer <dfnsonfsduifb at gmx.de> wrote:
> Hello group,
> I'm looking for a Python function but have forgotten it's name.
> Essentially what I want is:
> class Foo():
> def bar(self):
> x = Foo()
> y = x.MAGIC("bar")
getattr() is the function you seek.
y = getattr(x, "bar")
> <bound method Foo.bar of <__main__.Foo instance at 0xb7e11fcc>>
More information about the Python-list