Skip to main content

Unix whereis-like python script and package to find the source file of python object (package, module, function, class ...).

Project description

Summary
=======
Locate a python object (package, module, function, class ...) source file.

Usage
=====

``pywhereis [-v] [-s] dotted_name...``

CMD line Examples
=================

- The ``pywhereis`` script accept a package, module, function or a class ::

$ pywhereis shlex
shlex: /usr/lib/python2.6/shlex.py
$ pywhereis os.path.abspath
os.path.abspath: /usr/lib/python2.6/posixpath.py 337

- You can pass more than one dotted-name to it ::

$ pywhereis shlex inspect.ismodule
shlex: /usr/lib/python2.6/shlex.py
inspect.ismodule: /usr/lib/python2.6/inspect.py 51

- If the name is a function, class or method the result will contain the line
number where the object is defined ::

$ pywhereis unittest.TestCase.assertEqual
unittest.TestCase.assertEqual: /usr/lib/python2.6/unittest.py 344

- It will **fail** localizing object that are not pure python ::

$ pywhereis.py sys
sys:

- For more info about why the localization fail you can use the verbose
mode ::

$ pywhereis -v sys
sys: Error: <module 'sys' (built-in)> is built-in.

- If it's run with -s, --site-packages option the script will check first in
site-packages instead of the default which is to check in the current dir
first ::

$ cd ~ ; touch os.py
$ pywhereis os
os: /home/mouad/os.py
$ pywhereis -s os
os: /usr/lib/python2.6/os.py

- Of course you can search in a different python version by running this
script using that version ::

$ python3.2 /path/to/pywhereis html
html: /usr/local/lib/python3.2/html/__init__.py

- For python2.7 and above you can also do ::

$ python2.7 -mwhereis subprocess.Popen
subprocess.Popen: /usr/local/lib/python2.7/subprocess.py 33


Code Examples
=============

This package come also with a python package ``whereis`` that can be used like
so ::

>>> import whereis
>>> whereis.resolve('sys')
<module 'sys' (built-in)>
>>> whereis.locate('os')
'/usr/lib/python2.6/os.py'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywhereis-0.0.2.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file pywhereis-0.0.2.tar.gz.

File metadata

  • Download URL: pywhereis-0.0.2.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pywhereis-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f04abbcfe3e85027441e61e72d3da16e734e02a9a375e5976375be5accd01eab
MD5 5a2a800269e985bffcb8db00ac9e977a
BLAKE2b-256 cca8ccce4e06b1d3a456716b5ade3dc3d7a0189a1911e22a9ccc677842769c9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page