Is it really worth it?

Fact is, while it can shave off some lines of code, 
I think it is interesting to know _which_ lines of code - 

Usually when one writes a decorator, it is expected that they
will know what they are writing, and will  want to be in control of
their code. Delegating this to a decorator-decorator that is to be
copied and pasted, and will definitely change call-order, and when
your decorator is called, is something that I, at least, would be wary
to use.

Meanwhile, when I want this pattern, it really takes me 2 LoC inside
the decorator to have the same functionality, and still be 100% in control
of when my function is called:

```
from functools import partial

def mydecorator(func=None, /, *, param1=None, **kwargs):
     if func is None:
          return partial(mydcorator, param1=None, **kwargs)
     # decorator code goes here
    ...
```

So, yes, your proposal has some utility - but I consider it to be marginal -
it is the kind of stuff that I'd rather see on a 3rdy party package
with extra-stuff to help building decorators than on stdlib. 

On Mon, 30 Nov 2020 at 17:04, Yurii Karabas <1998uriyyo@gmail.com> wrote:
The idea of `decorator_factory` is to eliminate boilerplate code that used to create a decorator with parameters.

A perfect example is how `dataclass` decorator can be simplified from this:
```
def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False,
              unsafe_hash=False, frozen=False):
    def wrap(cls):
        return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)

    # See if we're being called as @dataclass or @dataclass().
    if cls is None:
        # We're called with parens.
        return wrap

    # We're called as @dataclass without parens.
    return wrap(cls)
```
To this:
@functools.decorator_factory
def dataclass(cls, /, *, init=True, repr=True, eq=True, order=False,
              unsafe_hash=False, frozen=False):
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
```
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/NMCDVBOYFXEKZ4L3ASLNYL2NBATJ3VCX/
Code of Conduct: http://python.org/psf/codeofconduct/