by mellavora · 3y ago · 0 comments
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.
IIRC, they're syntactic sugar over "string".format(locals())
https://docs.python.org/3/library/string.html#format-string-... https://docs.python.org/3/reference/lexical_analysis.html#f-...
print as a statement is inconsistent and surprising, but the explanation is shallow--they made an exception for print, that's all there is to it. It's not beautiful but it is unlikely to cause a 2 hour debugging session.
I'll also note that the OP focused on how "fun" Ruby was. Ruby is beautiful and fun.
Going back to the original question: why did Python grow more than Ruby? My first answer was going to be a rhetorical question: which beautiful and fun language has been the most successful?
C isn't especially beautiful or fun, not in the same way. (It has a nice minimalism and connection to the hardware maybe.) C++ is beautiful--is a thing that nobody has ever said. Java ain't beautiful. JavaScript, Python, etc, none are especially beautiful or fun.
I think another answer to the OPs question is that beautiful and fun languages are, apparently, not what most people are looking for. Evidently we should not expect a language to succeed because it is beautiful and / or fun.
Ruby’s beginner-friendliness and consistent OO design managed to help it expand in the early aughts and Rails brought the language to prominence in 2005, but by that time Python was already replacing Perl in its niche and had support from giants like Google.
Ruby got more adoption than would have been predicted based on its late entrance and lack of truly differentiating features, and that’s a credit to its ergonomics, community and how easy it is to learn.
Designing it correctly is an art