3 ms·
Thanks! i didn't know about these and will check them out for sure. Tired of `if key in hash:` nested layers.
by irjustin 3y ago
Thanks! i didn't know about these and will check them out for sure. Tired of `if key in hash:` nested layers.
- nicolaslem 3y agoIn 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.