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

Stefan Krah stefan at bytereef.org
Fri Apr 1 04:01:56 EDT 2016


Mike Miller <python-ideas at ...> writes:
> The fact that the class definition doesn't require empty parentheses works 
> against a few of these arguments.  I like Mahan's idea and don't find it 
> confusing, though I agree it isn't a big pain point either way.

There is a difference. Classes can be used like C-structs:

>>> class the_struct:
...     x = 10
...     y = 20
... 
>>> the_struct.x
10
>>> the_struct.y
20
>>> 


In order to use equational reasoning, functions need the empty
argument list in the definition:

>>> def f(): return 10 * 20
... 
>>> f() == 10 * 20
True
>>> f == 10 * 20
False


Read: We define f, when applied to the empty argument list, to equal
10 * 20.

f by itself does not equal 10 * 20. It is a function symbol.



Stefan Krah













More information about the Python-ideas mailing list