On 29 December 2010 13:36, Michael Foord fuzzyman@voidspace.org.uk wrote:
Hello all,
I often use python as a calculator or for simple operations using -c. It would be enormously useful if python -c "..." would output on stdout the result of the last evaluated expression in the same way that the interactive interpreter does.
The following outputs nothing:
python -c "12 / 4.1"
So you always have to prefix expressions with print to see the result.
I like the idea, but that's a fairly big semantic change. What about adding an -e option that takes an expression, and prints its value? So you'd have
python -e "12 / 4.1"
(AFAICT, -e is unused at present).
Paul.