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

Mahan Marwat mahanmarwat at gmail.com
Thu Mar 31 20:12:56 EDT 2016


> Alexander Walters <tritium-list at sdamon.com> wrote:
> > While it would be consistent, and if you suggested it in 1991 probably
> should have been included... are the two extra keystrokes really a problem?


I born in 1994. So, no chance of suggestion in 1991.
It is not about the keystrokes. Its about the visual cluttering. (and yes
it can save two keystrokes too and also four on Seven R. Kuze keyboard :-) )

As I have been stated in the Subject. My idea is only about function
definition, not function calling.


> 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?


For readability (Readability counts).

> The less awkward characters we have, the more readable our code will be
> > (Beautiful is better then ugly).
> I don't think that function declarations missing the parens are more
> beautiful than them with the parens.


Some people argued that function definition with parenthesis seems to them
natural. But actually it seems to us natural, because we have been used to
it a-lot. IMHO parenthesisless functions definitions are natural and
readable.

The Zen also says:
> Special cases aren't special enough to break the rules.
> Why do you think that zero-argument functions are special enough to
> justify breaking the rules? Just to save two characters?


I think empty parenthesis for no apparent reason does not make any sense.

When I was a beginner, I found that it was very helpful that I *always*
> needed to use parens after functions:


We are beginner only for once and expert for life.
Between you can asked in your novice level, that why there are empty
parenthesis if a function don't have parameters?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160401/fc8d4730/attachment-0001.html>


More information about the Python-ideas mailing list