Get for Python Lists
With python’s dictionary objects, you have the useful get method: >>> d = {'a':1, 'b':2, 'c':3} >>> d.get('a') 1 >>> d.get('d', 'not found') 'not found' Sometimes, I find something like this would be useful for lists, using the list’s index in place of the dict’s key: >>> l = [0,1,2,3] >>> l.get(2) Traceback (most recent [...]