-7
votes

Why python can't omit parentheses in a function call just like some other language(coffeescript haskell) do? Just some historical reason or what?

2
I'm going with the minus 100 points principle: every neat feature that requires actual work to implement, must have a significant net positive on the product, and preferably be something the customers actually want. It's not clear to me that parentheses omission qualifies for either. - Kevin
The fact that there is diversity is always for historical reasons. Other choices could have been made, but maybe the name wouldn't have been Python then. Who would I be if I wasn't me? - Jacques de Hooge
I just wonder why the question get's that many downvotes. Isn't it a valid question for a beginner (that can be answered rather objectively)? - Falko
Why would you want to omit the parentheses? What, if anything, do you think you'd gain? Python's development has long prioritised developer productivity and (per the Zen of Python, import this), "There should be one-- and preferably only one --obvious way to do it." - jonrsharpe
@prodev_paris that's not a good example - that works in 2.x because print is a statement in that version, not a function. - jonrsharpe

2 Answers

7
votes

The parentheses allow us to disambiguate the function object, func, from the calling of the function, func().

Function objects are first-class objects in Python. You can, for instance, pass them as arguments to functions, just like any other object. This is often used to set a callback function -- a common practice in GUI programming or concurrent programming.

2
votes

In python you can refer to the function itself, without running it. It is useful to define callbacks for instance.

So you need paranthesis to differentiate between a function call (you run it an consider its result) versus just refering to this function (without running it).