has_method

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


>#- Does anyone knows how to tell if an object has a method with a given
>#- name? How can I access that method?
>
>  
>
>>>>class C:
>>>>        
>>>>
>        def mymeth(self):
>                return
>
>       
>  
>
>>>>c = C()
>>>>dir(c)
>>>>        
>>>>
>['__doc__', '__module__', 'mymeth']
>  
>
>>>>c.mymeth
>>>>        
>>>>
><bound method C.mymeth of <__main__.C instance at 0x009ACBC0>>
>  
>
You are right - I only used dir() interactively. I have the answer, how 
to check.
But how can I access that method? I would like to call it by name. :-)

Best,

   Laci 2.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040831/e2c82226/attachment.html>


More information about the Python-list mailing list