2 ms·
.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 inpu
by stevesimmons 5y ago
.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"!