Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80848

Re: Where is inspect() located?

References <CA+FnnTw0+kB2AJmUKK9o_WO18TxA5E52L4UgDRo=LnYQcmOkoQ@mail.gmail.com>
Date 2014-11-16 15:29 +1100
Subject Re: Where is inspect() located?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15864.1416112165.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Nov 16, 2014 at 3:12 PM, Igor Korot <ikorot01@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Where is inspect() located? Chris Angelico <rosuav@gmail.com> - 2014-11-16 15:29 +1100

csiph-web