On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy <[email protected]> wrote:
> On 1/23/2016 8:58 AM, Chris Angelico wrote:
>> On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano <[email protected]>
>> wrote:
>>> [steve@ando ~]$ python -c "for i in range(5):
>>>>
>>>> print 'hello world'
>>>> "
>>>
>>> hello world
>>> hello world
>>> hello world
>>> hello world
>>> hello world
>>> [steve@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).
--
https://mail.python.org/mailman/listinfo/python-list