On Wednesday, 14 March 2012 13:28:58 UTC, Cosmia Luna  wrote:
> class Foo(object):
>     def bar(self):
>         return 'Something'
> 
> func = Foo().bar
> 
> if type(func) == <type 'instancemethod'>: # This should be always true
>     pass # do something here
> 
> What should type at <type 'instancemethod'>?
> 
> Thanks
> Cosmia

import inspect
if inspect.ismethod(foo):
   # ...

Will return True if foo is a bound method.

hth

Jon
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to