[Python-ideas] for/else statements considered harmful

Devin Jeanpierre jeanpierreda at gmail.com
Thu Jun 7 11:28:49 CEST 2012


On Thu, Jun 7, 2012 at 4:31 AM, Yuval Greenfield <ubershmekel at gmail.com> wrote:
> On Thu, Jun 7, 2012 at 10:57 AM, Devin Jeanpierre <jeanpierreda at gmail.com>
> wrote:
>>
>> On Thu, Jun 7, 2012 at 3:23 AM, Yuval Greenfield <ubershmekel at gmail.com>
>> wrote:
>> > Personally I'd prefer "if not break:" over "else:" but as we're stuck
>> > where
>> > we are today I'm just going to encourage people not to use the construct
>> > at
>> > all.
>>
>> Why shouldn't people use for-else?
>>
>> -- Devin
>
>
> I believe using for/else will cause you and maintainers of your code to make
> more mistakes.

I don't follow. What mistakes would people make? Why would they make them?

Also, are you worried about people that read the documentation and
know what for-else does, or the people that don't or haven't read this
documentation? It's good practice to, when reading source code of an
unfamiliar language, try to read up on things you haven't seen yet --
although sometimes context seems good enough. If you are afraid that
this is someplace that context _seems_ good enough, but actually
_isn't_, that would be something to worry about (although I don't feel
that way).

-- Devin



More information about the Python-ideas mailing list