On Tue, Mar 3, 2009 at 3:12 AM, Johannes Bauer <dfnsonfsdu...@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):
>                pass
>
> x = Foo()
> y = x.MAGIC("bar")

getattr() is the function you seek.

y = getattr(x, "bar")

> print(y)
> <bound method Foo.bar of <__main__.Foo instance at 0xb7e11fcc>>

Cheers,
Chris

-- 
Shameless self-promotion:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to