Not coalescing around None-aware
Not coalescing around None-aware
Posted Dec 29, 2022 16:01 UTC (Thu) by NRArnot (subscriber, #3033)Parent article: Not coalescing around None-aware
In almost all contexts you can do
x = x or default
the exception being where x may have a falsy value which is not None and which you do not want to replace.
In all contexts you can do
( default if x is None else x)
I for one don't find the case for a slew of new operators overwhelming. I'm not sure they enhance code readability, and the above are not particularly verbose.