Why 'open' is not a function according to inspect module?

P

Peng Yu

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)

$ ./main.py
False
False
True

Help on built-in function open in module __builtin__:

open(...)
open(name[, mode[, buffering]]) -> file object

Open a file using the file() type, returns a file object. This is the
preferred way to open a file.
 
M

Mel

Peng said:
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)

help (inspect.isfunction) gives

Help on function isfunction in module inspect:

isfunction(object)
Return true if the object is a user-defined function.


Mel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top