Determining method type given its string name presentation and itscorresponding object reference.

Apple newtonapple at gmail.com
Sun Jul 31 23:16:47 EDT 2005


"or perhaps callable(getattr(obj, strg, None)) if the need is related
to
an unknown string which may be a callable attribute of an object whose
class is unknown ..."

Hm.. the problem is I cannot call getattr() at all.  Because getattr()
will call my __repr__() which will call another m() that will
eventually call getattr() again..  It's an infinite recursion.  In
general, I think every time you try to qualify a method attribute, e.g.
 obj.method, it'd actually end up making a call to __repr__()...

obj.method would usually get you this output:
 (<bound method Class_of_obj.method of "INSTANCE'S __repr__() CALL
HERE">)

More or less I am trying to understand what getattr did to figure out
the name "method" is actually a method (bounded or not).  This way I
can avoid the recursive call to __repr__().  I hope this clarifies my
question a bit?  

Thanks a lot for the help ;)




More information about the Python-list mailing list