[Python-ideas] python -c "..." should output result like the interpreter

Michael Foord fuzzyman at voidspace.org.uk
Wed Dec 29 16:00:56 CET 2010


On 29 December 2010 14:55, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Wed, 29 Dec 2010 13:36:53 +0000
> Michael Foord <fuzzyman at 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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101229/3bb9f140/attachment.html>


More information about the Python-ideas mailing list