Am I the only one who thinks it's a massive flaw that decorators that take args and decorators that don't are inherently different? That extra level of anonymous functions feels awful, and it's really confusing because a decorator that takes no args is @decorator whereas one that takes optional args is @decorator() if you just go with the defaults, and there is no way to make them both work. Also, I wish they would i…
Understanding Python Decorators
21–28 of 28 posts
Re: Understanding Python Decorators
#22Am I the only one who thinks it's a massive flaw that decorators that take args and decorators that don't are inherently different? That extra level of anonymous functions feels awful, and it's really confusing because a decorator that takes no args is @decorator whereas one that takes optional args is @decorator() if you just go with the defaults, and there is no way to make them both work. Also, I wish they would i…
Re: Understanding Python Decorators
#23Step 1: Huh, that's a pretty cool feature Step 2: I bet I could ... Step 3: Quick check of CPAN Step 4: Zounds. http://search.cpan.org/~erwan/Python-Decorator-0.03/lib/Pyth...
Not to mention, one could alter the implementation to remove the inconsistency people are complaining about in Python.
Re: Understanding Python Decorators
#24Re: Understanding Python Decorators
#25Re: Understanding Python Decorators
#26Am I the only one who thinks it's a massive flaw that decorators that take args and decorators that don't are inherently different? That extra level of anonymous functions feels awful, and it's really confusing because a decorator that takes no args is @decorator whereas one that takes optional args is @decorator() if you just go with the defaults, and there is no way to make them both work. Also, I wish they would i…
It only feels wrong because you think of them as decorators without arguments and decorators with arguments: they really are decorators stored in variables and decorators computed by function calls. :)
@a[1]
def f(x):
...Re: Understanding Python Decorators
#27Am I the only one who thinks it's a massive flaw that decorators that take args and decorators that don't are inherently different? That extra level of anonymous functions feels awful, and it's really confusing because a decorator that takes no args is @decorator whereas one that takes optional args is @decorator() if you just go with the defaults, and there is no way to make them both work. Also, I wish they would i…
I had a permission checking decorator that I allowed both syntaxes (the default permission check and a mre fine-grained check). The flaw makes for an ugly implementation.