I couldn't find it though it seemed to be terrible, so I made it. → ** pycd: cd
to python modules **
When writing a Python package, I often think that if I bring it from another package, it will be over soon.
In such a case, the tool for quickly moving to the directory of the package and grep
or viewing it with an editor is pycd
.
$ pycd requests
$ pwd
/usr/lib/python2.7/dist-packages/requests
$ grep 'def get(' *
api.py:def get(url, **kwargs):
cookies.py: def get(self, name, default=None, domain=None, path=None):
sessions.py: def get(self, url, **kwargs):
structures.py: def get(self, key, default=None):
$ pip install pycd
Add the following to ~ / .bashrc
(or .zshrc
).
source `which pycd.sh`
At this time, the important thing is to specify the name to be ʻimport as an argument or the name to be specified when installing with
pip, but I think that many people are accustomed to import, so that I made it. In that case, I couldn't do it with
pip show PAKAGE`, so I decided to make another tool:
$ pip show sklearn # does not work
$ pip show scikit-learn
---
Name: scikit-learn
Version: 0.16.1
Location: /usr/local/lib/python2.7/dist-packages
Requires:
That's pypack
, but I'll write it because it might be useful:
$ pypack find numpy
/usr/local/lib/python2.7/dist-packages/numpy
$ pypack list
numpy
sklearn
scipy
...
It's quite handy not only for finding reusable code, but also for finding bugs in dependent packages, so use it if you like.
Also, if you have a better tool, please let me know.
Recommended Posts