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

Emile van Sebille emile at fenx.com
Thu Aug 23 03:39:58 CEST 2001


Well, getattr et al better answer the question.  But to answer your
question, the eval wierdness was because a was embedded in a string.  ;-)

new mantra:  If you want to know the right way to do something, post a
response showing the wrong way to do it.  - Always works.  ;-)

--

Emile van Sebille
emile at fenx.com

---------
"Bengt Richter" <bokr at accessone.com> wrote in message
news:3b8449c4.200774979 at wa.news.verio.net...
> On Wed, 22 Aug 2001 14:21:34 -0700, "Emile van Sebille" <emile at fenx.com>
wrote:
>
> >Does this help get you started?
> >
> >
> >>>> class A:
> >...     def a(self):
> >...             print 'A.a()'
> >...
> >>>> class B(A):
> >...     pass
> >...
> >>>> eval('B.%s' % 'a')
> ><unbound method A.a>
> >
> What was that eval weirdness for? ;-)
>  >>> class A:
>  ...     def a(self):
>  ...             print 'A.a()'
>  ...
>  >>> class B(A):
>  ...     pass
>  ...
>  >>> B.a
>  <unbound method A.a>
>
> or am I missing something?




More information about the Python-list mailing list