On Wed, Jun 23, 2010 at 1:42 AM, Peng Yu <pengyu...@gmail.com> wrote: > '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?
$ python Python 2.6.5 (r265:79063, Jun 13 2010, 14:03:16) [GCC 4.4.4 (CRUX)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from inspect import isbuiltin, isclass, isfunction >>> type(str) <type 'type'> >>> isbuiltin(str), isclass(str), isfunction(str) (False, True, False) >>> def foo(): pass ... >>> type(foo) <type 'function'> >>> isbuiltin(foo), isclass(foo), isfunction(foo) (False, False, True) >>> type(open) <type 'builtin_function_or_method'> >>> isbuiltin(open), isclass(open), isfunction(open) (True, False, False) >>> Notice anything ? --James PS: The Python REPL is your friend :) -- -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list