|
|
|
|
|
by mellavora
1028 days ago
|
|
>New users wonder how to call functions. They form an intuition ("use parenthesis"), but it's unreliable. "Oh, parenthesis are optional--oh, parenthesis are only optional sometimes". print f"are you {sure} you need parenthesis to call a function in python" >Python is much more boring in this respect, users are more likely to form accurate intuitions. is defining a class the same as defining a function? What about functions implicitly defined when you define a class? __what__ is __with__ __some_words__? why do you need an empty file called init.py in the same directory as your actual code? |
|
This example doesn't call any functions. The print statement was removed in Python 3 and turned into a function, so you do need parentheses to call it and the example above is a syntax error. Python 2 (which had a print statement instead of a print function) didn't support f-strings. And f-strings, unlike JavaScript's template strings, are not function calls.
In other words, yes, you consistently use parentheses to call functions in Python.