yes for this case you will have to use @memoize() as all the arguments are optional ...
Thanks, J --- On Tue, 28/6/11, Ian Kelly <ian.g.ke...@gmail.com> wrote: From: Ian Kelly <ian.g.ke...@gmail.com> Subject: Re: Using decorators with argument in Python To: "Jigar Tanna" <poisonousratt...@gmail.com> Cc: python-list@python.org Date: Tuesday, 28 June, 2011, 10:50 PM On Tue, Jun 28, 2011 at 10:52 AM, Jigar Tanna <poisonousratt...@gmail.com> 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 The main concern I think is not with how the decorators are used but how they are designed. An argument-less decorator will normally be used as @memoize, and @memoize() will likely not work. A decorator with arguments that are all optional will normally be used as @memoize(), and @memoize will likely not work. This naturally leads to some confusion: do I need parentheses to use this particular decorator or not? As a personal design goal I try to make my decorators either take at least one required argument or take no arguments at all. This way it's either @memoize or @memoize(foo), but never just the confusing @memoize(). Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
-- http://mail.python.org/mailman/listinfo/python-list