A decade or so of Python programming, and I've never thought to "for-elif"
Chris Angelico
rosuav at gmail.com
Tue Nov 30 01:24:47 EST 2021
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