Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102073
| From | eryk sun <eryksun@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: import locale and print range on same line |
| Date | 2016-01-24 02:00 -0600 |
| Message-ID | <mailman.197.1453622476.15297.python-list@python.org> (permalink) |
| References | (1 earlier) <56a37b1e$0$1612$c3e8da3$5496439d@news.astraweb.com> <mailman.176.1453555148.15297.python-list@python.org> <56a383fa$0$1593$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqw_C_ju784fPcgOq5zgggOaFR_mwqupzLZd8kN-DOjBw@mail.gmail.com> <n81dsc$co5$1@ger.gmane.org> |
On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy <tjreedy@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@pearwood.info>
>> 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).
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
import locale and print range on same line raiwil@gmail.com - 2016-01-23 02:02 -0800
Re: import locale and print range on same line Marko Rauhamaa <marko@pacujo.net> - 2016-01-23 12:36 +0200
Re: import locale and print range on same line Vlastimil Brom <vlastimil.brom@gmail.com> - 2016-01-23 12:12 +0100
Re: import locale and print range on same line Ramo <raiwil@gmail.com> - 2016-01-23 03:57 -0800
Re: import locale and print range on same line Steven D'Aprano <steve@pearwood.info> - 2016-01-24 00:07 +1100
Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 00:19 +1100
Re: import locale and print range on same line Steven D'Aprano <steve@pearwood.info> - 2016-01-24 00:45 +1100
Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 00:58 +1100
Re: import locale and print range on same line Ramo <raiwil@gmail.com> - 2016-01-23 06:03 -0800
Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 01:53 +1100
Re: import locale and print range on same line Terry Reedy <tjreedy@udel.edu> - 2016-01-23 21:45 -0500
Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 13:51 +1100
Re: import locale and print range on same line eryk sun <eryksun@gmail.com> - 2016-01-24 02:00 -0600
csiph-web