I'd like to be able to conveniently navigate to the file where a Python value (function/class/constant) is defined. Most of the guides I can find for using ctags with Python suggest options that aren't supported by the various ctags-like programs that I've found.
I've tried using vanilla ctags (
/usr/bin/ctags on OS X), exuberant ctags (through brew), and etags (on OS X) to generate
tags files for a Python project and have been somewhat dissatisfied with the out of the box results.
If I navigate to the project root and run
ctags -R . I get a lot of lines like the following:
version_info api-docs/venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/chardet/__init__.py /^from sys import version_info$/;" i
A line like
from sys import version_info
appears literally in the Python source code.
version_info is defined in the
sys module, which should be somewhere in the standard library in my virtualenv. When you do an unqualified import in Python, you really are copying the contents of the symbol to a new symbol in the current module, but most of the time I just want to jump to the place where the symbol was originally defined.
I get that the actual place where a symbol is defined depends on information only available at runtime like the
PYTHONPATH, but a heuristic guess is better than nothing (there might also be a nice interface for cycling between symbols that are defined in multiple files built in to vim, I'm not sure).