[Python-ideas] Definition Symmetry (original) (raw)

Ethan Furman ethan at stoneleaf.us
Thu Jan 31 18:26:08 CET 2013


On 01/31/2013 09:15 AM, MRAB wrote:

On 2013-01-31 16:35, Jason Keene wrote:

Why do function definitions require parens?

class MyClass: ... pass ... def myfunc: File "", line 1 def myfunc: ^ SyntaxError: invalid syntax This seems to me to break a symmetry with class definitions. I assume this is just a hold off from C, perhaps there is a non-historical reason tho. The parentheses are always required when calling the function, so it makes sense to always require them when defining the function. The case with class definitions is different; they are used in the definition only when you want to specify the superclass.

... they are required in the definition when you want to specify the superclass, and optional otherwise.

Ethan



More information about the Python-ideas mailing list