Fast, Easy, Cheap: Pick One

Just some other blog about computers and programming

Quickly Open the Source of a Python Module From the Command-line

Add this to your .bashrc:

1
2
3
pysource() {
    $EDITOR $(python -c "import ${1}; import inspect; print inspect.getsourcefile(${1})")
}

Your favorite editor should pop up and you can browse the module source. If you want to open a module from an existing editor window, there’s probably plugins for that.

Then after reloading your .bashrc just run something like: $ pysource logging