[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Determining method type given its string name presentation and its
From:       "Apple" <newtonapples () gmail ! com>
Date:       2005-07-31 23:45:24
Message-ID: 1122853524.374812.326580 () g14g2000cwa ! googlegroups ! com
[Download RAW message or body]

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.

-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic