|
|
Subscribe / Log in / New account

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.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds