Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nicer multiple decorator support #40

Closed
tolomea opened this issue Apr 29, 2017 · 4 comments
Closed

nicer multiple decorator support #40

tolomea opened this issue Apr 29, 2017 · 4 comments

Comments

@tolomea
Copy link

tolomea commented Apr 29, 2017

I had a suggestion and wasn't sure where to put it, the basic idea is could the decorate function support multiple decorators in a single call so that:

def my_decorator(func):
    return decorate(decorate(func, _caller), _precondition_caller)

could be rewritten as:

def my_decorator(func):
    return decorate(func, _precondition_caller, _caller)

Maybe I'm just approaching decorator composition wrong, if so I'd love to see an alternative way.

@tolomea
Copy link
Author

tolomea commented Apr 29, 2017

So the precondition is usable by itself, so I also have this:

def precondition_decorator(func):
    return decorate(func, _precondition_caller)

Which I realize now allows this slightly tidier version

def my_decorator(func):
    return precondition_decorator(decorate(func, _caller))

@micheles
Copy link
Owner

micheles commented Jun 3, 2017

Closing since this is not an issue.

@micheles micheles closed this as completed Jun 3, 2017
@tolomea
Copy link
Author

tolomea commented Jun 3, 2017

@micheles is there somewhere else I should put it?

@micheles
Copy link
Owner

micheles commented Jun 3, 2017

No, it is simply that I have no interest in making the syntax for composing decorators easier. It is best not to stack together too many levels of decorators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants