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

2019-03-20 Thread Sylvain MARIE via Python-ideas
just there to give feedback from what I see of the python libs development community. -- Sylvain De : Python-ideas De la part de Christopher Barker Envoyé : mercredi 20 mars 2019 06:50 À : Greg Ewing Cc : python-ideas Objet : Re: [Python-ideas] Problems (and solutions?) in writing decorator

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

2019-03-19 Thread Christopher Barker
Also: @something def fun(): ... Is exactly the same as: def fun() ... fun = something(fun) So you can’t make a distinction based whether a given usage is as a decoration. -CHB On Tue, Mar 19, 2019 at 12:26 PM Greg Ewing wrote: > Sylvain MARIE via Python-ideas wrote: > > `my_decorator(foo)

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

2019-03-19 Thread Greg Ewing
Sylvain MARIE via Python-ideas wrote: `my_decorator(foo)` when foo is a callable will always look like `@my_decorator` applied to function foo, because that's how the language is designed. I don't think it's worth doing anything to change that. Everywhere else in the language, there's a very cl

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

2019-03-19 Thread Chris Angelico
On Wed, Mar 20, 2019 at 12:37 AM Sylvain MARIE via Python-ideas wrote: > > Stephen > > > If the answer is "maybe", IMO PyPI is the right solution for distribution. > > Very wise words, I understand this point. > However as of today it is *not* possible to write such a library in a > complete way,

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

2019-03-19 Thread Sylvain MARIE via Python-ideas
2019 04:56 À : Sylvain MARIE Cc : David Mertz ; python-ideas Objet : Re: [Python-ideas] Problems (and solutions?) in writing decorators [External email: Use caution with links and attachments] Sylvain MARIE via Python-ideas writes: > I totally und

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

2019-03-14 Thread Stephen J. Turnbull
Sylvain MARIE via Python-ideas writes: > I totally understand your point of view. However on the other hand, > many very popular open source projects out there have the opposite > point of view and provide decorators that can seamlessly be used > with and without arguments (pytest, attrs, clic

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

2019-03-14 Thread Sylvain MARIE via Python-ideas
ds Sylvain De : David Mertz Envoyé : mardi 12 mars 2019 19:15 À : Sylvain MARIE Cc : Steven D'Aprano ; python-ideas Objet : Re: [Python-ideas] Problems (and solutions?) in writing decorators [External email: Use caution with links and attachments] One of

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

2019-03-12 Thread David Mertz
opatch depends on makefun, so both come at the > same time when you install decopatch, and decopatch by default relies on > makefun when you use it in “double-flat” mode to create wrappers as > explained here https://smarie.github.io/python-decopatch/#even-simpler &g

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

2019-03-12 Thread Sylvain MARIE via Python-ideas
on-existent need ;) Kind regards -- Sylvain De : David Mertz Envoyé : mardi 12 mars 2019 15:30 À : Sylvain MARIE Cc : Steven D'Aprano ; python-ideas Objet : Re: [Python-ideas] Problems (and solutions?) in writing decorators [External email: Use caution with links and attachments] ___

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

2019-03-12 Thread David Mertz
gt; Decopatch even proposes a "double-flat" development style where you >> directly write the wrapper body, as explained in the doc. >> >> Did I answer your questions ? >> Thanks again for the quick feedback ! >> Best, >> >> Sylvain >> >&g

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

2019-03-12 Thread David Mertz
e doc. > > Did I answer your questions ? > Thanks again for the quick feedback ! > Best, > > Sylvain > > -Message d'origine----- > De : Python-ideas > De la part de Steven D'Aprano > Envoyé : mardi 12 mars 2019 12:30 > À : python-ideas@python.org

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

2019-03-12 Thread Sylvain MARIE via Python-ideas
2019 14:53 À : Steven D'Aprano ; python-ideas@python.org; David Mertz Objet : RE: [Python-ideas] Problems (and solutions?) in writing decorators David, Steven, Thanks for your interest ! As you probably know, decorators and function wrappers are *completely different concepts*. A decorat

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

2019-03-12 Thread Sylvain MARIE via Python-ideas
ined in the doc. Did I answer your questions ? Thanks again for the quick feedback ! Best, Sylvain -Message d'origine- De : Python-ideas De la part de Steven D'Aprano Envoyé : mardi 12 mars 2019 12:30 À : python-ideas@python.org Objet : Re: [Python-ideas] Problems (and solutions?

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
es an > equivalent of `@functools.wraps` that is truly signature-preserving (based > on the same recipe than `decorator`). > Once again, any feedback would be gladly appreciated ! > > Kind regards > > Sylvain > > -Message d'origine----- > De : Python-ideas >

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

2019-03-12 Thread Sylvain MARIE via Python-ideas
eas Objet : Re: [Python-ideas] Problems (and solutions?) in writing decorators [External email: Use caution with links and attachments] Jonathan Fine wrote: > I also find writing decorators a bit > hard. It seems to be something I have to learn a

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

2018-10-25 Thread Greg Ewing
Jonathan Fine wrote: I also find writing decorators a bit hard. It seems to be something I have to learn anew each time I do it. Particularly for the pattern @deco(arg1, arg2) def fn(arg3, arg4): > # function body Perhaps doing something with partial might help here. Anyone here intereste