Hello,
Currently the user defined functions are mutables, there can be existed
python codes like this:
>>> def foo():
... pass
...
>>> if not hasattr(foo, 'partial'):
... foo.partial = {}
...
Adding a new method to function object can break existing projects, but it
is without impact wit
>
> As attrgetter/itemgetter might get heterogeneus data, I would expect a
> per-get default, not [just] a global default.
>
+1
Perhaps something like:
>
> >>> itemgetter(-1, 0, -2,
> ...default0="first argument default",
> ...default1=["second", "argument", "default"],
>
Hi everybody,
> Have you encountered situations yourself where this would make a difference ?
I need to get multiple objects in several dicts using the same set of keys.
I wanted to use itemgetter to reduce the number of lines of code but I
have mixed up getattr/dict.get
that have default paramet
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', de