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

Joshua Morton joshua.morton13 at gmail.com
Thu Mar 31 17:24:42 EDT 2016


(Let's hope I'm doing this right)
…
 Hmmm. Although I like the lightness of this, it's somewhat confusing,
isn't?

It would also lead to parse errors, or alternatively parentheses being
required sometimes in the case of function calls as arguments

Take as an example a function with two functions being called as the
arguments:

    f(x(y, z), a(b, c))

with parentheses, however without you get

    f of x of y z a of b c

in the second case its ambiguous if f is a function on 3 arguments or two.
In other words, is the function f(x(y, z), a(b, c)) or f(x(y, z), a(b), c)?

This is also all against the Zen.
There should be one-- and preferably only one --obvious way to do it.

Regards,
Josh

On Thu, Mar 31, 2016 at 4:57 PM Sven R. Kunze <srkunze at mail.de> wrote:

> On 31.03.2016 20:06, Terry Reedy wrote:
>
>
> def greet: # note the missing parenthesis
>      print('hello')
>
>
> -1  This will lead people to think even more often than they do now that
> they can omit () in the call.
>
>
> Interesting that you mentioned it. Doesn't Ruby handle it this way?
>
> Let's see how this would look like in Python:
>
>
> def distance of point1, point2:
>     # Pythagoras
>
> point1 = (3, 1)
> point2 = (1, 4)
> print distance of point1, point2
>
>
> Hmmm. Although I like the lightness of this, it's somewhat confusing,
> isn't?
>
>
> Best,
> Sven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160331/499483c5/attachment.html>


More information about the Python-ideas mailing list