Re: Obtaining an member function by name

2005-11-19 Thread guy lateur
Thanks for the feedback, people. I actually only need the "bar" part (instance methods). I added the "foo" part to generalize the question without really thinking it through first. Still, it has gotten me more information than I ever imagined. So thanks again. g -- http://mail.python.org/m

Re: Obtaining an member function by name

2005-11-19 Thread Bengt Richter
On Sat, 19 Nov 2005 14:12:25 GMT, "guy lateur" <[EMAIL PROTECTED]> wrote: >Hi all, > >Suppose you have this class: > >class foo: >def bar(): > >Suppose you also have the strings "foo" and "bar". How can you obtain the >function foo.bar()? > >Surely somebody knows.. > Sorry, clean forgot about

Re: Obtaining an member function by name

2005-11-19 Thread EuGeNe
guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. > > TIA, > g > > Would that do? >>> class foo: @staticmeth

Re: Obtaining an member function by name

2005-11-19 Thread Bengt Richter
On Sat, 19 Nov 2005 14:12:25 GMT, "guy lateur" <[EMAIL PROTECTED]> wrote: >Hi all, > >Suppose you have this class: > >class foo: >def bar(): > >Suppose you also have the strings "foo" and "bar". How can you obtain the >function foo.bar()? Why don't you type these things into an interactive py

Re: Obtaining an member function by name

2005-11-19 Thread Diez B. Roggisch
guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. getattr helps. However, your example won't work: it misses either a sta

Re: Obtaining an member function by name

2005-11-19 Thread [EMAIL PROTECTED]
f = getattr(obj,"bar") f() guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. > > TIA, > g -- http://mail.python.org/mailman

Obtaining an member function by name

2005-11-19 Thread guy lateur
Hi all, Suppose you have this class: class foo: def bar(): Suppose you also have the strings "foo" and "bar". How can you obtain the function foo.bar()? Surely somebody knows.. TIA, g -- http://mail.python.org/mailman/listinfo/python-list