[Python-ideas] Control Flow - Never Executed Loop Body

Stephen J. Turnbull stephen at xemacs.org
Thu Mar 24 14:04:22 EDT 2016


Andrew Barnert via Python-ideas writes:

 > If you have a _different_ implementation, I'm happy to hear it. I
 > supplied all the versions I could think of because another critic
 > (Stephen? I forget...)

I presented a good try at a one-extra-line pure Python implementation
(which is still good enough that I'm -1 on syntax, and waiting for a
compelling use case for adding "for ... except").

It was Chris Angelico who shot a hole in it with locals().values().

 > implied that what you wanted was impossible or incoherent, and it
 > clearly isn't.

I don't think there was ever a claim that it was incoherent/impossible
or even inefficient at C-level.

The point of the mildly obscure[1] item = sentinel idiom was to show
that syntax isn't needed to avoid changing the loop body.  I don't
even know if Chris A would disagree that I succeeded well enough.


Footnotes: 
[1]  I know that several people found the item = _sentinel approach
unreadable.  Which surprised me: I'm usually the one who takes hours
to understand the TOOWTDI one-liner.  Maybe my newt-ness got bettah!



More information about the Python-ideas mailing list