Using decorators with argument in Python
Lie Ryan
lie.1296 at gmail.com
Tue Jun 28 13:06:35 EDT 2011
On 06/29/2011 02:52 AM, Jigar Tanna wrote:
> coming across to certain views from people, it is not a good practice
> to use
> decorators with arguments (i.e. @memoize() ) and instead it is good to
> just
> use @memoize. Can any of you guys explain me advantages and
> disadvantages of
> using each of them
Simplicity is one, using @decor() means you have at least three-level
nested functions, which means the code is likely to be very huge and
perhaps unnecessarily.
However, there is nothing wrong with using decorators with arguments;
except that if you have a simpler alternative, then why use the more
complex ones?
More information about the Python-list
mailing list