Where is inspect() located?

Chris Angelico rosuav at gmail.com
Sat Nov 15 23:29:22 EST 2014


On Sun, Nov 16, 2014 at 3:12 PM, Igor Korot <ikorot01 at gmail.com> wrote:
> In the https://docs.python.org/2/library/inspect.html, it says it is
> located in Lib/inspect.py.
>
> What am I missing? Or its only for 3.x?

You need to import it. If you're curious, you can find out exactly
where it's imported from like this:

Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> inspect.__file__
'/usr/lib/python2.7/inspect.pyc'

The path will be different on your system, as this is a Debian box,
but the technique is the same. However, all that matters is that you
hadn't imported it. The Lib directory is one of the places where
importable modules are found.

ChrisA



More information about the Python-list mailing list