Created
December 18, 2010 15:14
-
-
Save msabramo/746585 to your computer and use it in GitHub Desktop.
Bash function and alias for evaluating Python expressions from the Bash command-line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_pyval() { | |
local python_cmd="print $@" | |
python -c "${python_cmd}" | |
case "$shopts" in | |
*noglob*) ;; | |
*) set +f;; | |
esac | |
unset shopts | |
} | |
alias pyval='shopts="$SHELLOPTS"; set -f; _pyval' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://marc-abramowitz.com/archives/2010/12/17/quick-evaluation-of-python-expressions-in-bash/