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

Michael Foord fuzzyman at voidspace.org.uk
Wed Jan 5 14:28:30 CET 2011


On 29 December 2010 15:45, Michael Foord <fuzzyman at voidspace.org.uk> wrote:

>
>
> On 29 December 2010 15:18, Georg Brandl <g.brandl at gmx.net> wrote:
>
>> Am 29.12.2010 15:46, schrieb Michael Foord:
>>
>> >     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).
>> >
>> > 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.
>>
>> Hey, what about this little module:
>>
>> import sys
>> for x in sys.argv[1:]:
>>    exec compile(x, '<cmdline>', 'single')
>>
>> Then:
>>
>> $ python -me '1+1; 2+2'
>> 2
>> 4
>>
>
> So now you can `pip install e` and then `python -me`...
>


Just as a follow up, for which we should still be blaming Georg, you can now
do `pip install oo` followed by `python -moo`.

(Requires pygame - tested on Linux and Mac should be cross platform.)

All the best,

Michael Foord

>
> Michael
>
>
>>
>> Georg
>>
>> _______________________________________________
>> 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
>
>
>


-- 

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/20110105/331abfed/attachment.html>


More information about the Python-ideas mailing list