Earlier quoted context omitted.
What would qualify as clever Python? These kind of broad and vague statements make me wonder if I am guilty..
For a simple example, I think the walrus operator (:=) could be considered clever. I like it, and use it, but the fact that you can declare a variable, store a value in it, and then perform actions depending on its value, all in one line, gives me pause. if (foo := bar()) is not None: baz(foo) Whereas the traditionally accepted Python method of dealing with this would be EAFP: try: foo = bar() baz(foo) except Attribu…
Where are you expecting an AttributeError to come from? Why are you comfortable catching them from anything inside of the baz(...) invocation?
The traditional method would be to just bind it and check for a null outside the expression.
foo = bar()
if foo is not None:
baz(foo)
I don't know why people insisted on pretending binding variables before using them was such a difficulty that it was worth altering the language. Lazy and bad programmers aren't going to stop being lazy and bad when you hand them the ability to name things willy nilly. They'll just use that badly as well.