3 ms·
I don't mind the "try ... except" version for the cases where most of the time the key will be present. Two reasons for this: 1) the "except" semantics help hi
by throwaway274739 10y ago
I don't mind the "try ... except" version for the cases where most of the time the key will be present. Two reasons for this:
1) the "except" semantics help hit home the point you expect the key to be there most of the time
2) in cases where the exception will rarely be raised, the "try ... except" route runs faster than the ".get() ... if" route.