Skip to main content

Welcome to pyloc

Build Status

pyloc prints the location of the definition of any python object in your file-system.

Introduction

pyloc is very similar to what python3 -m inspect -d <object> offers. However, it is only focused to retrieve the file name (and eventually the line number) where a given Python object is defined. The object can be a package, module, class, method or function.

pyloc makes some further efforts to figure out the line and column number and its output is formatted so that it can easily be passed to emacsclient or vi.

pyloc works with Python 2.7, 3.2, 3.3, 3.4 and 3.5.

Examples

You can see the location of Popen.wait method in the sub-process package:

$ python -m pyloc -f human subprocess:Popen.wait
Filename: /Users/polrop/.pyenv/versions/2.7.9/lib/python2.7/subprocess.py
Line: 1379

$ python -m pyloc -f human email.utils:formataddr
Filename: /Users/polrop/.pyenv/versions/2.7.9/lib/python2.7/email/utils.py
Line: 85

(Output may be different on your system if you have different installation path and version)

Note that the object naming syntax is as follow: module[:qualname]

To open it in Emacs you can do:

$ emacsclient `python -m pyloc -f emacs subprocess:Popen.wait`

or in vim:

$ vim `python -m pyloc -f vi subprocess:Popen.wait`

If you are lazy typing -f <format> all the time and you often use the same format, you can set the default output format this way (you can add this line in your .zshenv or .bashrc):

$ export PYLOC_DEFAULT_FORMAT=emacs

pyloc will always locate object based on the python interpreter your are using:

$ python3 -m pyloc -f human subprocess:Popen.wait
Filename: /Users/polrop/.pyenv/versions/3.4.3/lib/python3.4/subprocess.py
Line: 1526

$ /usr/local/bin/python -m pyloc -f human email.utils:formataddr
Filename: /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py
Line: 85

$ /usr/bin/python -m pyloc -f human email.utils:formataddr
Filename: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py
Line: 85

Installation

Using pip

You can install pyloc using pip like this:

$ pip install pyloc

or

$ pip3 install pyloc

Directly from the source

$ git clone https://github.com/nicolasdespres/pyloc.git
$ cd pyloc
$ python setup.py develop

To uninstall it, you ca do:

$ python setup.py develop --uninstall

However, this won’t remove the entry script generated by easy install.

Known bugs

  • Classes or built-in types like int or str do not contain location information. In this case pyloc tries to look for the name in the AST. This procedure may not be accurate since Python is a dynamic language.

Hacking

See HACKING for details.

Release notes

See the corresponding tag annotation. After cloning you can do for instance:

$ git show v0.1.10

License

pyloc is released under the term of the Simplified BSD License. Copyright (c) 2015, Nicolas Desprès All rights reserved.

As noted in the source code, some part has been inspired by code from the inspect module written by Ka-Ping Yee <ping@lfw.org> and Yury Selivanov <yselivanov@sprymix.com> form the Python 3.4.3 distribution (see the LICENSE file in the python distribution)

Metadata

Release files for pyloc 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyloc 0.1.10
File Size Uploaded Provenance Actions
pyloc-0.1.10.tar.gz 11.5 kB Without provenance Details for pyloc-0.1.10.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyloc 0.1.10
File Interpreter ABI Platform Actions
pyloc-0.1.10-py3-none-any.whl Python 3 none any Details for pyloc-0.1.10-py3-none-any.whl
pyloc-0.1.10-py2-none-any.whl Python 2 none any Details for pyloc-0.1.10-py2-none-any.whl

Total release size: 37.7 kB

Release files / pyloc-0.1.10.tar.gz

Download URL pyloc-0.1.10.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e5bdb0efa149d6ab98ea0f4cdacac3d6ea4de7664ecd41f58555a317591e34da
BLAKE2b-256 checksum
How to use checksums
12c7cff0fc2a32dbe85fd12c8e32a426584d6d46948357ebf142b88400b5f853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyloc-0.1.10-py3-none-any.whl

Download URL pyloc-0.1.10-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccb1ad17e2356fa0f21e0d5cccbc1ef67804bd8dfa3b0e44ead446918c9f7363
BLAKE2b-256 checksum
How to use checksums
bbe73650c4c0a9377019bf55dc558aea28a38fc444f210c2b7cf6f6e951450dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyloc-0.1.10-py2-none-any.whl

Download URL pyloc-0.1.10-py2-none-any.whl
Size 13.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
32026348cc9b04e5bdc59f6d9c2b7ddd530d5a8fec2fc4d412079db226464a71
BLAKE2b-256 checksum
How to use checksums
5ee6cd40d4f7d7b9e46bd79c0abef26347f6d73e4c460309602dfa24761a8bf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyloc 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page