On Tue, Nov 12, 2013 at 2:45 PM, Xuancong Wang
As you know, reading from and writing to IO is a high frequency operation. By entropy coding theorem (e.g. Huffman coding), an efficient language should assign shorter language code to more frequent tasks. Typing a '(' requires holding SHIFT and pressing 9, the input effort is much higher than that in Python 2. Also, specifying IO has changed from >>* to file=*, which also becomes more inconvenient.
Yes, I/O is a very common operation; but not all I/O gets its own statement. Python doesn't have a keyword for reading input (REXX, for instance, has 'say' for output and 'pull' for input), and admittedly output IS more common than input, but I still don't see that having a keyword for one of them is really beneficial. Advantages of print being a function: * You can override it. Can't do that with a special language element. * It can be used in map, lambda, and other expression contexts. * Precedence etc follows the normal rules of functions - the arguments are all tidily enclosed. * Keyword arguments, rather than magical syntax, handle the oddities like end=" ". * You can easily alias it: "p = print; p('Hello, world!')" Advantages of print being a statement: * You don't have to hit Shift to create console output. Parsimony is important in design. Why have a statement when it can just be a built-in? Every keyword needs to justify itself, and far more than just "make this faster to type". Console output is common, but not half as common as, say, assignment, which is why assignment gets an extremely short and easy-to-type token. Basic arithmetic gets operators; "square root" doesn't, it just gets a named function. The less the language has to do (and the more the standard library does), the easier the language is to grok.
From the Zen of Python: Special cases aren't special enough to break the rules.
The rule is that function-like operations get called as functions. Maybe this would be a small benefit, but the cost of special-casing print is high. Anyway, you already get a single function name for it - it's not "sys.stdout.write(...)" - so it's already been given quite a boost in readability :) ChrisA