import locale and print range on same line

Chris Angelico rosuav at gmail.com
Sat Jan 23 21:51:37 EST 2016


On Sun, Jan 24, 2016 at 1:45 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> C:\Users\Terry>python -c "for i in range(5):\n\tprint('hello world')"
>   File "<string>", line 1
>     for i in range(5):\n  print('hello world')
>                                              ^
> SyntaxError: unexpected character after line continuation character
>
> -c does not preprocess the code string before executing.  I may propose that
> it do so.

As an alternative, maybe multiple -c parameters could result in
multiple lines? Something like:

python3 -c "for i in range(5):" -c " print('Hello, world')"

Currently, a second -c is unparsed (it ends up in sys.argv), so this
would technically be a behavioural change (but then, so would
preprocessing).

ChrisA



More information about the Python-list mailing list