Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: "import posix" question

Tags:

python

posix

If I import os module, I can run the following to infer the location of os.py

>>> import os
>>> print os.__file__
/usr/lib/python2.6/os.pyc

However, when I import posix, it does not have the __file__ attribute. Is it because it is implemented as a part of the python runtime, not as a standard library?

How can I find out more information like this using solely the python official documentation?

like image 470
Anthony Kong Avatar asked Jun 17 '11 06:06

Anthony Kong


2 Answers

It's a C module. It can be either built into the Python binary or compiled as a shared library. In your case it is compiled in

The official docs say not to import it directly, and you should use the functionality provided via os

like image 103
John La Rooy Avatar answered Sep 20 '22 12:09

John La Rooy


Run python interactively.

>>> import posix
>>> help(posix)

There's a lot of good stuff there.

FILE
    (built-in)
like image 27
Chris Eberle Avatar answered Sep 18 '22 12:09

Chris Eberle