A
Apple
Hi I am a bit new to python. I was wondering if there is a way to
determine whether or not a given string is a member method of a given
object:
def is_a_method(self, attr_name):
'returns True if attr_name is an instance method of self; false
otherwise'
The problem is that I have overridden __repr__ in such a way that it's
not self-contained. It makes a call to a member method, call it m(),
that would call up getattr() which eventually makes another call back
to __repr__:
Example output:
(<bound method Class.attr_name of "INSTANCE'S __repr__() HERE">).
So, I want to trap all attr_name that are methods comeing into m() and
make sure they're not passed on to getatrr() i.e. making __repr__
self-contained (hopefully).
Is there a simple way to determine a given attr_name is_a_method()?
Thanks in advance for all your help.
determine whether or not a given string is a member method of a given
object:
def is_a_method(self, attr_name):
'returns True if attr_name is an instance method of self; false
otherwise'
The problem is that I have overridden __repr__ in such a way that it's
not self-contained. It makes a call to a member method, call it m(),
that would call up getattr() which eventually makes another call back
to __repr__:
Example output:
(<bound method Class.attr_name of "INSTANCE'S __repr__() HERE">).
So, I want to trap all attr_name that are methods comeing into m() and
make sure they're not passed on to getatrr() i.e. making __repr__
self-contained (hopefully).
Is there a simple way to determine a given attr_name is_a_method()?
Thanks in advance for all your help.