import locale and print range on same line

Chris Angelico rosuav at gmail.com
Sat Jan 23 08:58:06 EST 2016


On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote:
>
>> On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano <steve at pearwood.info>
>> wrote:
>>> On Sat, 23 Jan 2016 09:02 pm, raiwil at 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.
>
>
> [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... and not everyone
knows you can do that. That said, though... this is a good reason for
giving full context for the question. "I'm trying to X, but I get this
error because of Y. How would I go about fixing Y?" - response:
"Actually, you can do X in a slightly different way.".

Just sayin', there might be other reasons for wanting to put things
onto one line.

ChrisA



More information about the Python-list mailing list