Behavior of the for-else construct

Chris Angelico rosuav at gmail.com
Fri Mar 4 18:31:20 EST 2022


On Sat, 5 Mar 2022 at 10:28, Peter J. Holzer <hjp-python at hjp.at> wrote:
>
> On 2022-03-04 11:34:07 +1100, Chris Angelico wrote:
> > On Fri, 4 Mar 2022 at 10:09, Avi Gross via Python-list
> > <python-list at python.org> wrote:
> > > The drumbeat I keep hearing is that some people hear/see the same
> > > word as implying something else. ELSE is ambiguous in the context it
> > > is used.
> >
> > What I'm hearing is that there are, broadly speaking, two types of
> > programmers [1]:
> >
> > 1) Those who think about "for-else" as a search tool and perfectly
> > understand how it behaves
> > 2) Those who have an incorrect idea about what for-else is supposed to
> > do, don't understand it, and don't like it.
>
> 3) Those who understand what it does und don't even find it*s syntax
> very confusing, yet only very rarely find it useful.
>
> I have probably used it a handful of times in 8 years of Python
> programming. Coincidentally, I think I used it just this week - but I
> can't find it any more which probably means that it was either in a
> throwaway script or I have since rewritten the code.
>

Part of group 1. It doesn't matter how often or rarely you use the
feature; there are a LOT of features of Python that I use only
occasionally, if ever. But as long as you know how to use it, it's
there when you need it.

ChrisA


More information about the Python-list mailing list