has_method

From: Gandalf (gandalf_at_geochemsource.com)
Date: 08/31/04


Date: Tue, 31 Aug 2004 15:13:23 +0200
To: python-list@python.org


  Hi All!

Does anyone knows how to tell if an object has a method with a given
name? How can I access that method?

For attributes, it is easy:

class A(object):
    a = 12
    b = 'Python'

a = A()
a.__dict__.has_key('a') # True
a.__dict__.has_key('b') # True
a.__dict__.has_key('c') # False

But it won't work for methods. Thanks in advance.

  Laci 2.0