News for hackers. Stuff that matters.
Re:Python 3.11: “Zero cost” exception handling by stevesimmons on Wednesday October 06, 2021 @11:05AM (#28774018)
.get("key") is enough, as the default is already None.

And if you care about the default value being a particular type, when there may also be None in the input stream, do something like:

x.get("key") or []

or

str(x.get("key") or "") # Guarantee strings and avoid "None"!

There are no comments on this comment yet.