
On 25/07/18 23:11, Abe Dillon wrote:
The problem here is not whether it's explicit. It's about Readability and conciseness. Using symbols in place of words almost always harms readability in favor of conciseness.
value = person.name if person.name else person
ITYM value = person.name if person.name is not None else None
almost reads like english (aside from being a weird and totally uncommon use case)
I think Nicholas (?) was right to observe that it's uncommon to not want to know where a deeply nested attribute access failed. Exactly what you want to do when an underlying library (presumably) has "helpfully" turned non-existent attributes into Nones is going to vary tremendously from application to application. On the other hand, value = parameter ?? default encapsulates a very common usage, and doesn't read badly compared with: value = parameter if parameter is not None else default which is a tad wordy. That example isn't too bad, but replace "parameter" with "spam.spam.spam.eggs" and DRY suddenly becomes a rather more important principle :-) -- Rhodri James *-* Kynesim Ltd