Package: pyloc
pylocprints the location of the definition of any python object in
your file-system.Introductionpylocis very similar to whatpython3-minspect-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.pylocmakes some further efforts to figure out the line and column
number and its output is formatted so that it can easily be passed
toemacsclientorvi.ExamplesYou can see the location ofPopen.waitmethod in the sub-process package:$python-mpyloc-fhumansubprocess:Popen.waitFilename:/Users/polrop/.pyenv/versions/2.7.9/lib/python2.7/subprocess.pyLine:1379$python-mpyloc-fhumanemail.utils:formataddrFilename:/Users/polrop/.pyenv/versions/2.7.9/lib/python2.7/email/utils.pyLine: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, syntaxmodule[.qualname]a la pydoc is also
supported.To open it in Emacs you can do:$emacsclient`python-mpyloc-femacssubprocess:Popen.wait`or in vim:$vim`python-mpyloc-fvisubprocess: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.zshenvor.bashrc):$exportPYLOC_DEFAULT_FORMAT=emacspylocwill always locate object based on thepythoninterpreter
your are using:$python3-mpyloc-fhumansubprocess:Popen.waitFilename:/Users/polrop/.pyenv/versions/3.4.3/lib/python3.4/subprocess.pyLine:1526$/usr/local/bin/python-mpyloc-fhumanemail.utils:formataddrFilename:/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.pyLine:85$/usr/bin/python-mpyloc-fhumanemail.utils:formataddrFilename:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.pyLine:85InstallationUsing pipYou can installpylocusingpiplike this:$pipinstallpylocor$pip3installpylocDirectly from the source$gitclonehttps://github.com/nicolasdespres/pyloc.git$cdpyloc$pythonsetup.pydevelop# If you also want it for Python 3$python3setup.pydevelopNote that if you also install the Python 3 version, thepyloc2command line driver will not work but thepylocdriver will point
to the Python 2 installation.To uninstall it, you ca do:$pythonsetup.pydevelop--uninstall# And if you installed the Python 3 version$python3setup.pydevelop--uninstallHowever, this won’t remove the entry scripts generated by easy
install.Known bugsClasses or built-in types like int or str do not contain location
information. In this casepyloctries to look for the name in the
AST. This procedure may not be accurate since Python is a dynamic
language.HackingSeeHACKINGfor details.Release notesSee the corresponding tag annotation. After cloning you can do for instance:$gitshowv0.1.10Licensepylocis released under the term of theSimplified 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
theinspectmodule 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)