Re: import locale and print range on same line

2016-01-24 Thread eryk sun
On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy wrote: > On 1/23/2016 8:58 AM, Chris Angelico wrote: >> On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano >> wrote: >>> [steve@ando ~]$ python -c "for i in range(5): print 'hello world' " >>>

Re: import locale and print range on same line

2016-01-23 Thread Ramo
This works also but I thought it was possible to do it easier: import locale; locale.setlocale(locale.LC_ALL, ""); print('\n'.join(locale.format("%2f", i, 1) for i in range(1,20,4))) -- https://mail.python.org/mailman/listinfo/python-list

Re: import locale and print range on same line

2016-01-23 Thread Vlastimil Brom
2016-01-23 11:36 GMT+01:00 Marko Rauhamaa : > rai...@gmail.com: > >> Can someone tell me why next code doesn't work? >> >> import locale; locale.setlocale(locale.LC_ALL, ""); for i in >> range(1,20,4): print(locale.format("%2f", i, 1)) >> >> It gives an error: SyntaxError:

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano wrote: > On Sat, 23 Jan 2016 09:02 pm, rai...@gmail.com wrote: > >> However I need to put the code on one single line. > > Why? Is the Enter key on your keyboard broken? Maybe it's for a python -c invocation. ChrisA --

Re: import locale and print range on same line

2016-01-23 Thread Ramo
The reason why I want to have it on onto one line has nothing to do with my question, "why doesn't it work on one line" :) But if you want to know it, I use this python code in the commandline of a texteditor :) Btw.. thank you all for your help. Very happy with it :) --

Re: import locale and print range on same line

2016-01-23 Thread Steven D'Aprano
On Sat, 23 Jan 2016 09:02 pm, rai...@gmail.com wrote: > However I need to put the code on one single line. Why? Is the Enter key on your keyboard broken? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: import locale and print range on same line

2016-01-23 Thread Steven D'Aprano
On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote: > On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano > wrote: >> On Sat, 23 Jan 2016 09:02 pm, rai...@gmail.com wrote: >> >>> However I need to put the code on one single line. >> >> Why? Is the Enter key on your keyboard

Re: import locale and print range on same line

2016-01-23 Thread Marko Rauhamaa
rai...@gmail.com: > Can someone tell me why next code doesn't work? > > import locale; locale.setlocale(locale.LC_ALL, ""); for i in > range(1,20,4): print(locale.format("%2f", i, 1)) > > It gives an error: SyntaxError: invalid syntax --> indicating 'for' > > However I need to put the code on one

import locale and print range on same line

2016-01-23 Thread raiwil
Can someone tell me why next code doesn't work? import locale; locale.setlocale(locale.LC_ALL, ""); for i in range(1,20,4): print(locale.format("%2f", i, 1)) It gives an error: SyntaxError: invalid syntax --> indicating 'for' However I need to put the code on one single line. When I separate

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano wrote: > On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote: > >> On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano >> wrote: >>> On Sat, 23 Jan 2016 09:02 pm, rai...@gmail.com wrote: >>> However I

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 1:03 AM, Ramo wrote: > The reason why I want to have it on onto one line has nothing to do with my > question, "why doesn't it work on one line" :) > > But if you want to know it, I use this python code in the commandline of a > texteditor :) Called

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 1:45 PM, Terry Reedy wrote: > C:\Users\Terry>python -c "for i in range(5):\n\tprint('hello world')" > File "", line 1 > for i in range(5):\n print('hello world') > ^ > SyntaxError: unexpected character

Re: import locale and print range on same line

2016-01-23 Thread Terry Reedy
On 1/23/2016 8:58 AM, Chris Angelico wrote: On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano wrote: On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote: On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano wrote: On Sat, 23 Jan 2016 09:02 pm,