On Tue, Jun 22, 2010 at 9:42 AM, Peng Yu <pengyu...@gmail.com> wrote: > Hi, > > 'open' is not a function according to inspect module. But according to > help(open), it is a function. Is there something wrong with inspect > module? > > $ cat main.py > #!/usr/bin/env python > > import inspect > > def hello(): > print "Hello World!" > return > > print inspect.isfunction(str) > print inspect.isfunction(open) > print inspect.isfunction(hello)
inspect.isfunction returns True if the object is a *user-defined* function. For built-in functions, use inspect.isbuiltin. You might also be interested in the callable() function, which returns True if the object is any object that can be called. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list