Hacker News new | ask | show | jobs
by ptx 1028 days ago
> print f"are you {sure} you need parenthesis to call a function in python"

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.

2 comments

> And f-strings, unlike JavaScript's template strings, are not function calls.

IIRC, they're syntactic sugar over "string".format(locals())

With the exception of properties, of course.