Skip to content

Instantly share code, notes, and snippets.

@teepark
Created March 14, 2014 17:27
Show Gist options
  • Save teepark/9552594 to your computer and use it in GitHub Desktop.
Save teepark/9552594 to your computer and use it in GitHub Desktop.
python_run() {
$@ 2>.pythonrunerr
if [ $? -ne 0 ]; then
sed -nri -e '/^\s*File/N' -e 's/^\s*?File "(.*?)", line (.*?),.*\n(.*)$/\1:\2:\3/p' .pythonrunerr
vim -q .pythonrunerr -c cope
else
cat .pythonrunerr >&2
fi
rm .pythonrunerr
}
$ python_run ./test.py
#!/usr/bin/env python
import os, sys
def a():
b()
def b():
c()
def c():
d()
def d():
e() #NameError
def main(env, argv):
a()
return 0
if __name__ == '__main__':
exit(main(os.environ, sys.argv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment