A decade or so of Python programming, and I've never thought to "for-elif"
Rob Cliffe
rob.cliffe at btinternet.com
Thu Dec 2 00:18:32 EST 2021
If for ... else was spelt more intelligibly, e.g. for ... nobreak, there
would be no temptation to use anything like `elif'. `nobreakif' wouldn't
be a keyword.
Rob Cliffe
On 30/11/2021 06:24, Chris Angelico wrote:
> for ns in namespaces:
> if name in ns:
> print("Found!")
> break
> elif name.isupper():
> print("All-caps name that wasn't found")
>
> This actually doesn't work. I have been programming in Python for well
> over a decade, and never before been in a situation where this would
> be useful.
>
> As YAGNIs go, this is right up there.
>
> (For the record, since this was the last thing in the function, I just
> made the break a return. Alternatively, an extra indentation level
> "else: if name.isupper():" wouldn't have been that terrible.)
>
> Your random piece of amusement for today.
>
> ChrisA
More information about the Python-list
mailing list