Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-12 Thread Chris Barker via Python-ideas
Just in case I'm not the only one that had a hard time finding the latest version of this PEP, here it is in the PEPS Repo: https://github.com/python/peps/blob/master/pep-0584.rst -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread David Mertz
One of the nice things in wrapt is that Dumpleton lets you use the same decorator for functions, regular methods, static methods, and class methods. Does yours handle that sort of "polymorphism"? FWIW, thanks for the cool work with your libraries! I don't think I will want the specific with-or-w

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread Sylvain MARIE via Python-ideas
Thanks David, > I did write the book _Functional Programming in Python_, so I'm not entirely > unfamiliar with function wrappers. Nice ! I did not realize ; good job here, congrats! ;) -- I carefully read the documentation you pointed at, https://wrapt.readthedocs.io/en/latest/decorators.html#

Re: [Python-ideas] Suggestions: dict.flow_update and dict.__add__

2019-03-12 Thread Christopher Barker
On Fri, Mar 8, 2019 at 1:52 AM Jonathan Fine wrote: > I've just learnt something new. Look at > > >>> from operator import iadd > >>> lst = [1, 2, 3] > >>> iadd(lst, 'hi') > [1, 2, 3, 'h', 'i'] > >>> lst > [1, 2, 3, 'h', 'i'] > > This shows that the proposals dict.flow_upd

Re: [Python-ideas] Dict joining using + and +=

2019-03-12 Thread Christopher Barker
> This question is probably on its own a valid argument against the > proposal. When it comes to dicts (and not Mappings in general) {**d1, > **d2} or d.update() already have clearly-defined semantics. Actually, in my mind, this is an argument for an operator (or method) — besides being obtuse, t

Re: [Python-ideas] Preallocated tuples and dicts for function calls

2019-03-12 Thread Jeroen Demeyer
On 2019-03-08 22:16, Martin Bammer wrote: Hi, what about the idea that the interpreter preallocates and preinitializes the tuples and dicts for function calls where possible when loading a module? The basic premise here is wrong: function calls using the METH_FASTCALL convention don't need t

Re: [Python-ideas] Left arrow and right arrow operators

2019-03-12 Thread Nick Timkovich
In general, there is lots of code out in the wild that can't be updated for whatever reason, e.g. the person that knows Python left and it needs to continue to work. Weak argument, but cost-benefit I think it comes out ahead. In your example there isn't a reason I can tell why swapping the operands

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread David Mertz
The documentation for wrapt mentions: Decorators With Optional Arguments Although opinion can be mixed about whether the pattern is a good one, if the decorator arguments all have default values, it is als

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread David Mertz
The wrapt module I linked to (not funtools.wraps) provides all the capabilities you mention since 2013. It allows mixed use of decorators as decorator factories. It has a flat style. There are some minor API difference between your libraries and wrapt, but the concept is very similar. Since yours

[Python-ideas] Add method unittest.TestProgram to add custom arguments

2019-03-12 Thread Rémi Lapeyre
Hi everybody, I would like to add a new method to unittest.TestProgram that would let the user add its own arguments to TestProgram so its behavior can be changed from the command line, and make them accessible from a TestCase. This would allow for more customization when running the tests. Curr

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread Sylvain MARIE via Python-ideas
David I realize that you were pointing at the 'wrapt' library not the functools.wrapt library. >From what I have tried with that library, it does not solve the issue solved >with decopatch. Sylvain -Message d'origine- De : Sylvain MARIE Envoyé : mardi 12 mars 2019 14:53 À : Steven D'

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread Sylvain MARIE via Python-ideas
David, Steven, Thanks for your interest ! As you probably know, decorators and function wrappers are *completely different concepts*. A decorator can directly return the decorated function (or class), it does not have to return a wrapper. Even more, it can entirely replace the decorated item w

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread Steven D'Aprano
On Tue, Mar 12, 2019 at 09:36:41AM +, Sylvain MARIE via Python-ideas wrote: > I therefore proposed > https://smarie.github.io/python-makefun/ . In particular it provides > an equivalent of `@functools.wraps` that is truly signature-preserving Tell us more about that please. I'm very interes

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread David Mertz
What advantage do you perceive decopatch to have over wrapt? ( https://github.com/GrahamDumpleton/wrapt) On Tue, Mar 12, 2019, 5:37 AM Sylvain MARIE via Python-ideas < python-ideas@python.org> wrote: > Dear python enthusiasts, > > Writing python decorators is indeed quite a tideous process, in pa

Re: [Python-ideas] Problems (and solutions?) in writing decorators

2019-03-12 Thread Sylvain MARIE via Python-ideas
Dear python enthusiasts, Writing python decorators is indeed quite a tideous process, in particular when you wish to add arguments, and in particular in two cases : all optional arguments, and one mandatory argument. Indeed in these two cases there is a need to disambiguate between no-parenthes