Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-11 Thread Vincent Maillol
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

Re: [Python-ideas] Add "default" kw argument to operator.itemgetter and operator.attrgetter

2018-05-08 Thread Vincent Maillol
> > 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"], >

Re: [Python-ideas] Add "default" kw argument to operator.itemgetter and operator.attrgetter

2018-05-07 Thread Vincent Maillol
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

[Python-ideas] Add "default" kw argument to operator.itemgetter and operator.attrgetter

2018-05-02 Thread Vincent Maillol
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