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

Joao S. O. Bueno jsbueno at python.org.br
Thu Mar 31 22:37:53 EDT 2016


On 31 March 2016 at 14:57, Steven D'Aprano <steve at pearwood.info> wrote:
> On Thu, Mar 31, 2016 at 09:29:36PM +0500, Mahan Marwat wrote:
>
>> I have an idea of making parenthesis optional for functions having no
>> parameters. i.e
>>
>> def greet: # note the missing parenthesis
>>     print('hello')
>
> -1
>
> I don't think that the benefit (two fewer characters to type) is worth
> the effort of learning the special case. Right now, the rule is simple:
> the def keyword ALWAYS needs parentheses after the name of the function,
> regardless of whether there is one argumemt, two arguments, twenty
> arguments, or zero arguments. Why treat zero as special?

Because class definitions already do so?

So, if it is possible to omit parentheses when inheriting from the
default object when declaring a class, not needing parenthesis for
default parameterless functions would not be an exception - it would
be generalizing the idea of "Python admits less clutter".


For that, I'd think of this a good idea - but I don't like changing
the idea syntax in such a fundamental way - so I am +0 on this thing.

I think this can be an interesting discussion - but I dislike people
taking a ride on this to suggest omitting parentheses on function
calls as well - that is totally broken. :-)

  js
 -><-


More information about the Python-ideas mailing list