On 29 December 2010 14:55, Antoine Pitrou <solipsis@pitrou.net> wrote:
On Wed, 29 Dec 2010 13:36:53 +0000
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.

Is sparing the need to type print() really worthwhile here?


Well, what usually happens is that I forget I have to print and do it without first. Then when there is no output I remember and redo with the print in place. Making the print unnecessary would therefore mean substantially less than half as much typing....

Michael
 
I often leave a Python interpreter prompt open in a terminal so that I
can try out whatever I need there, so I don't have to type "python -c",
I can reuse previous results and imports, etc.
Unless you are severaly RAM-limited (or OS X has poor multiwindowing
capabilities ;-)), this should probably suit you as well.

Regards

Antoine.


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas



--
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html