Tag Archives: Python

Quickly open the source of a Python module from the command-line

Add this to your .bashrc: 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 … Continue reading

Posted in Programming | Tagged , | View Comments

Easy context managers with contextlib

Do you ever use some functions in Python that you wish had a context manager, but do not? Are you too lazy to write one? Then use the contextlib module! I often need to work with gzipped files, but unfortunately … Continue reading

Posted in Programming, Python | Tagged | View Comments