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
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to