4 ms·
I actually worked on teaching my 71 year old father Python using this book. One point of difficulty that struck me during that exercise was that I as a program
by top1nice1gtsrtd 11y ago
I actually worked on teaching my 71 year old father Python using this book. One point of difficulty that struck me during that exercise was that I as a programmer had completely internalized the idea that an open paren and a close paren right after a function is a natural way to invoke a function with zero arguments (e.g.: exit() exits Python's prompt. exit doesn't.). The whiplash I felt from finding the questioning of the convention silly to finding the convention silly was amusing to feel. Like it makes sense to a parser but not to a flesh-and-blood contextual-clues-using human. We don't vocalize "open paren close paren" whenever we say an intransitive verb. We just "know" that it's intransitive. Anyway, great article.
- jackmaney 11y agoPerl doesn't require "()" after the name of a function to call the function. In fact, parentheses aren't required for function calls at all. The code: use strict; use warnings; sub foo { print "In foo\n"; print "args = " . join(",",@_) . "\n" if @_; } foo; foo "a", "b", "c"; yields the output: In foo In foo args = a,b,c
- tehwalrus 11y agoNeither does ruby. (Which is really really confusing if you spend your days in python, and occasionally have to edit something in ruby.)
- rhinoceraptor 11y agoIt's even more confusing if you have to figure out if you're calling a method or referencing a variable. The code could be assigning a new variable from a method return value, or just from an existing variable.
- deleted 11y ago[deleted]
- pdw 11y agoIt is a silly convention, really. Algol-60 didn't require them, and neither did any language in the Algol family (Pascal, Ada, Modula-2, etc). It used to be something peculiar to Fortran and C, but today every language imitates C...
- icebraining 11y agoDid Algol-60 have first class functions? It's not like Python just forces you to type the parenthesis to be meticulous; not typing them is perfectly valid code, it just means a different thing.
- Tenobrus 11y agoBut there's a good reason for that convention in any language with first class functions. Otherwise you would have something inconsistent like "no parens required if the call is on a line by itself, but they are required in any other expression" (i.e. assignment or another function call).
- reagency 11y agoWhy do you put "ing" at the end of "finding" when it is obvious what you mean from just "find"? English is so silly.
- reagency 11y agoWhy do you put "ing" at the end of "finding" when it is obvious what you mean from just "find"? English is so silly.