3 ms·
In my opinion, a better alternative to nested `if key in hash`: try: value = data["foo"]["bar"]["baz"] except KeyError: value = None
by nicolaslem 3y ago
In my opinion, a better alternative to nested `if key in hash`:
try:
value = data["foo"]["bar"]["baz"]
except KeyError:
value = None
- irjustin 3y agoI know it's been almost a year but I still haven't accepted this pattern. Using errors as general flow control makes me uncomfortable. It shouldn't be an error or exception except in.... Actual problems.