Skip to main content

Welcome to pyloc

Build Status Coverage Status Last released version Supported python versions Download rate Package stability License

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.

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] Since version 0.2.0, syntax module[.qualname] a la pydoc is also supported.

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
# If you also want it for Python 3
$ python3 setup.py develop

Note that if you also install the Python 3 version, the pyloc2 command line driver will not work but the pyloc driver will point to the Python 2 installation.

To uninstall it, you ca do:

$ python setup.py develop --uninstall
# And if you installed the Python 3 version
$ python3 setup.py develop --uninstall

However, this won’t remove the entry scripts 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-2106, 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.2.0

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

Source distributions (sdists)

Source distribution for pyloc 0.2.0
File Size Uploaded
pyloc-0.2.0.zip 23.1 kB Details
pyloc-0.2.0.tar.gz 16.3 kB Details

Built distributions (wheels)

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

Total release size: 71.9 kB

Release files / pyloc-0.2.0.zip

Download URL pyloc-0.2.0.zip
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d186218bdb3e05145907adca1cf44a1d00637f2dac2415bb7c165cf7c58954bc
BLAKE2b-256 checksum
How to use checksums
6f742c7c773805ccd97e002c7e0d5deb74dec26623850348cd23369abbe2da87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyloc-0.2.0.tar.gz

Download URL pyloc-0.2.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
30186816cea04587363aec8c097e1f9b5b269b50c139469ad0f833940eab2b3d
BLAKE2b-256 checksum
How to use checksums
2823651d4a290774714015922bac4ebf78c6b5f1f9bc7c85a912f1eece9180d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pyloc-0.2.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd59c29d7fc302feefcda2065fe69aa6010a2726f9f80f34b88c54d82f468b5c
BLAKE2b-256 checksum
How to use checksums
880176d7019002945da0ae33361f2de45e38e2697e971a5ee12bfc43ade490ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pyloc-0.2.0-py2-none-any.whl
Size 16.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
3d1c54f347977e9722e6a249267353d193f98608e7a93995222619d0aaffa470
BLAKE2b-256 checksum
How to use checksums
bd1542408c2b7d0005cfa7bc0e69790913ac4f8bb24f3d32a77d660553281377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

4 release files

0.1.9

3 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

1 release file

0.1.1

2 release files

0.1.0

1 release file

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