3 ms·
Whhats wrong with 7.?
by phaer 12y ago
Whhats wrong with 7.?
- tomp 12y agoThe default value (the second argument of the `get` method) defaults to `None` anyways. Therefore, D.get(key, None) is just syntax noise (in the best case - in the worst case, it signifies someone who doesn't know/understand Python). D.get(key) should be used instead, or D.get(key, "whatever") if required.
- bpeebles 12y agoOf course, sometimes I still type: D.get(key, None) since I forget that dict.get and getattr() have different behavior in the case of missing keys/attributes...