untested def my_getter(m, i, f): try: return m[i] except (KeyError, IndexError): return f()
my_getter(d, 'x', bigscaryfunction) my_getter(d, 'y', lambda: scaryinlineexpresion)
pgp04VRKFqQL1.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list