Add "default" kw argument to operator.itemgetter and operator.attrgetter
2 May
2018
2 May
'18
4:08 p.m.
Hi everybody, Our PEP idea would be to purpose to add a global default value for itemgeet and attrgetter method. This was inspired from bug 14384 (https://bugs.python.org/issue14384); opened by Miki TEBEKA. For example, we could do: p1 = {'x': 43; 'y': 55} x, y, z = itemgetter('x', 'y', 'z', default=0)(values) print(x, y, z) 43, 55, 0 instead of: values = {'x': 43; 'y': 55} x = values.get('x', 0) y = values.get('y', 0) z = values.get('z', 0) print(x, y, z) 43, 55, 0 The goal is to have have concise code and improve consistency with getattr, attrgetter and itemgetter What are you thinking about this? MAILLOL Vincent GALODE Alexandre
2173
Age (days ago)
2179
Last active (days ago)
13 comments
7 participants
participants (7)
-
Danilo J. S. Bellini
-
Guido van Rossum
-
Raymond Hettinger
-
Rob Cliffe
-
Serhiy Storchaka
-
Steven D'Aprano
-
Vincent Maillol