[Python-ideas] Make parenthesis optional in parameterless functions definitions

Ethan Furman ethan at stoneleaf.us
Fri Apr 1 10:47:02 EDT 2016

On 04/01/2016 03:10 AM, Sven R. Kunze wrote:
> On 01.04.2016 11:52, Terry Reedy wrote:
>> On 4/1/2016 5:25 AM, Sven R. Kunze wrote:
>>> I remember this "issue" with decorators as well.
>>> @property
>>> def foo....
>>> @lru_cache()    # really?
>>> def bar...
>> There is a sematic difference between the two examples. The ()s are
>> not optional. 'property' is a decorator that is applied to foo after
>> it is defined.  'lru_cache()' is a function call that returns a
>> decorator. Quite different.
> @Terry
> Thanks for snipping away the relevant explanation and not addressing my
> point. >.<

Your "point" appears to be that ()s are optional in the case of 
decorators, and they are not -- decorators don't need them, and can't 
have them*, while functions that return a decorator do need them and 
must have them.

If you meant something else please offer a better explanation -- no need 
to be snide with Terry.


* Okay, it is possible to write a decorator that works either with or 
without parens, but it's a pain, not general-purpose, and can be 
confusing to use.

More information about the Python-ideas mailing list