has_method

Gandalf gandalf at geochemsource.com
Tue Aug 31 09:13:23 EDT 2004


  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





More information about the Python-list mailing list