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

Michael Foord fuzzyman at voidspace.org.uk
Wed Dec 29 16:13:24 CET 2010


On 29 December 2010 15:09, Paul Moore <p.f.moore at gmail.com> wrote:

> On 29 December 2010 14:46, Michael Foord <fuzzyman at voidspace.org.uk>
> wrote:
> > That would be great. I did worry that changing the output would be
> backwards
> > incompatible with code that shells out to Python using "-c", so a
> different
> > command line option would be great. So long as it works with multiple
> > statements (semi-colon separated) like the current "-c" behaviour.
> >
> > I use this trick for finding the source code of Python modules:
> >
> > $ python -c "import os;print os.__file__[:-1]"
> > /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.py
>
> I'd suggest allowing multiple -c and -e options, interspersed as
> needed, with each being treated as a separate line, so you could do
>
> $ python -c "import os" -e "os.__file__[:-1]"
>
> (Actually, I'd find "python -c stmt1 -c stmt2" mildly more readable
> than "python -c "stmt1; stmt2"" so that's another (equally small)
> benefit to me...)
>

Well, I'd like both. :-)



>
> Paul.
>
> PS I take Antoine's point that it's a small benefit, but like you, I
> find myself needing it quite a lot in practice :-)
>

Ditto.

Michael Foord

-- 

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/daa98dbc/attachment.html>


More information about the Python-ideas mailing list