Looping [was Re: Python and the need for speed]

bartc bc at freeuk.com
Sun Apr 16 12:05:38 EDT 2017


On 16/04/2017 15:22, Chris Angelico wrote:
> On Sun, Apr 16, 2017 at 11:57 PM, bartc <bc at freeuk.com> wrote:
>> Technically, adding this one feature to Python /is/ trivial, for example,
>> allowing while: as a synonym for while True:, but preferably using a new
>> keyword such as loop. Nothing else needs to be touched. And it could have
>> been done right at the start when the politics was simpler.
>>
>> But people just don't want it.
>>
>> /That/ is what surprises me, when people reject things that to me are
>> no-brainers.
>
> Maybe it's not a no-brainer to them. Maybe you need to make the case that:
>
> 1) It's worth stopping people from using the word "loop" as a variable

Actually I think 'loop' could still be used as a variable, since 'name:' 
wouldn't occur in any other contexts. But a dual purpose 'loop' wouldn't 
be elegant.

> 2) It's worth documenting another type of loop
> 3) It's worth having everyone need to know how to read another type of loop

Compared to all the other stuff in Python, seriously? Lambdas, 
listcomps, generators, iterators, decorators, subclassing, class and 
instance attributes, ... no problemo.

But faced with:

   loop: print ("Hi!")

will lead to head-scratching?!

> What's the benefit, aside from avoiding discussions like this?

Imagine if the discussion was instead about introducing a negate 
operator so that you could write:

   a = -b

instead of having to write:

   a = 0 - b

It wouldn't be a big deal having to do the latter, but it's nicer not to.

I just find writing 'while 1' (or while (1) or for(;;) elsewhere) an 
annoyance.

-- 
bartc



More information about the Python-list mailing list