[Python-ideas] Problems (and solutions?) in writing decorators

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Thu Mar 14 23:55:49 EDT 2019


Sylvain MARIE via Python-ideas writes:

 > I totally understand your point of view. However on the other hand,
 > many very popular open source projects out there have the opposite
 > point of view and provide decorators that can seamlessly be used
 > with and without arguments (pytest, attrs, click, etc.). So after a
 > while users get used to this behavior and expect it from all
 > libraries. Making it easy to implement is therefore something quite
 > important for developers not to spend time on this useless
 > “feature”.

That doesn't follow.  You can also take it that "educating users to
know the difference between a decorator and a decorator factory is
therefore something quite important for developers not to spend time
on this useless 'feature'."

I'm not a fan of either position.  I don't see why developers of
libraries who want to provide this to their users shouldn't have "an
easy way to do it", but I also don't see a good reason to encourage
syntactic ambiguity by providing it in the standard library.  I think
this is a feature that belongs in the area of "you *could* do it, but
*should* you?"  If the answer is "maybe", IMO PyPI is the right
solution for distribution.

Steve

-- 
Associate Professor              Division of Policy and Planning Science
http://turnbull.sk.tsukuba.ac.jp/     Faculty of Systems and Information
Email: turnbull at sk.tsukuba.ac.jp                   University of Tsukuba
Tel: 029-853-5175                 Tennodai 1-1-1, Tsukuba 305-8573 JAPAN


More information about the Python-ideas mailing list