import locale and print range on same line
eryk sun
eryksun at gmail.com
Sun Jan 24 03:00:34 EST 2016
On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 1/23/2016 8:58 AM, Chris Angelico wrote:
>> On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano <steve at pearwood.info>
>> wrote:
>>> [steve at ando ~]$ python -c "for i in range(5):
>>>>
>>>> print 'hello world'
>>>> "
>>>
>>> hello world
>>> hello world
>>> hello world
>>> hello world
>>> hello world
>>> [steve at ando ~]$
>>
>> Well, not everyone's shells are as awesome as bash...
>
> Like Windows command prompt is not. I tried:
>
> 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
cmd's parsing can be inscrutably finicky and limited, but luckily
enough this example works:
C:\>py -2 -c ^
More? "def f(n):^
More?
More? for i in range(n):^
More?
More? print 'hello world'^
More?
More? f(5)
hello world
hello world
hello world
hello world
hello world
cmd prints the "More?" prompt when a line is continued. Note that it's
necessary to hit enter again after escaping the first enter. Also, as
is usual with cmd, the closing double quote is optional, so I omitted
it after f(5).
More information about the Python-list
mailing list