|
|
|
|
|
by knome
751 days ago
|
|
What? Those aren't equivalent at all. 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. |
|
As to your example, both LBYL and EAFP are accepted Python standards.