for / while else doesn't make sense

Grant Edwards grant.b.edwards at gmail.com
Sat May 21 11:20:17 EDT 2016


On 2016-05-21, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Sat, May 21, 2016 at 5:26 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>
>> Does anyone know of other languages that include the same feature?
>> It's very rare for Python to innovate in language features.
>>
>> (I wonder if it came from ABC?)
>
> According to Raymond Hettinger starting at about 15:50 in this
> video:
>
> http://pyvideo.org/video/1780/transforming-code-into-beautiful-idiomatic-pytho
>
> It was invented by Donald Knuth (including the choice of keyword).

If true, that alone dismisses with prejudice any question of changing it.

As if backwards compatibility weren't a compelling enough argument.

Besides which, I happen to think it makes sense the way it is.

[I haven't been paying very close attention to this thread for a
while, so I assume that "this feature" and "it" still refer to having
an else clause in for/while loops?]

I can't count the number of times I've wished C had such a feature,
and have sometimes resorted to using a "goto" to get the same
semantics in an easy to read/understand way.

--
Grant




More information about the Python-list mailing list