Hi Vincent,

Your idea is interesting but we are worried that there are not enough real
use cases where it would be useful. Have you encountered situations
yourself where this would make a difference? I am asking not for clarifying
examples (you already provided one and from that it's perfectly clear to me
what you are proposing) but for real-world code that would benefit from
this addition to the itemgetter API.

--Guido

On Wed, May 2, 2018 at 1:08 AM, Vincent Maillol <vincent.mail...@gmail.com>
wrote:

> 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/
>



-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
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