3 ms·
For what it's worth, I only use x.get when having a missing key is a normal and expected part of the process. If I need to be able to expect a key to be in the
by CalRobert 3y ago
For what it's worth, I only use x.get when having a missing key is a normal and expected part of the process. If I need to be able to expect a key to be in the dict then I'll use x[] so I can get a useful exception for debugging. Though really, this should only happen with validated inputs, and as Python adopts more type hinting dealing with this should get easier over time.