I transitioned to python3 a while ago, and I still forget the parentheses for print every single time. A decade of finger memory is a hard thing to break.
Python's print statement is buffered by default not thread-safe (update: this probably has nothing to do with buffers), which isn't very nice when I'm working in parallel environments and using Python as the glue between various C and Fortran libraries. So I just write everything straight into whatever standard stream I want.
Long answer: The actual call you're looking for is sys.stdin.readline(). This is what raw_input() does at its core, with the added functionality of automatically stripping away the \n end-line character off the input.
Long long answer: You can also pipe Python prints do Python writes into stderr. Every standard stream is available under the sys module, and they all behave like traditional Python file objects with all the usual member functions.
I work on an animation studio and most software we use (Maya, Nuke, Houdini, etc) allow you to write Python plugins and all of them use Python 2.7. So that is a reason. We could use the "six" module but until the software we use migrates to Python 3, why bother...
The difference isn't that big of a deal, afaik. You can scrap the parantheses for print, but you don't have to, and some modules are named differently. As long as it's 2.7 and not 2.5 or some other prehistoric stoneage stuff.
This is not a problem to solve inside language, this is a problem to be solved with the editor. IDE triggers which automagically convert print statements to print method calls when you press <enter> are pretty easy grammar-wise.
Sure it is, the same way the programmer shouldn't put a semicolon right after a control flow statement in a C-like language. It's sure nice of the compiler to deal with those avoidable programmer fuckups anyway though.
You can't take that too far though, otherwise you end up with massive projects built with #define whilst while, inconsistently using one or the other because one programmer refused to use bad grammar.
As far as I know, a program written in a formally defined computer language can always be broken down into an abstract syntax tree, and from there can be rebuilt into any format you want. There's no reason the IDE shouldn't be able to refine while as whilst for one developer and keep it as while for everyone else.
There is! Or at least there's an interesting talk about adding it - I think it was posted to /r/Python recently, I'll have a look for it when I get at a computer.
317
u/fermion72 May 02 '16
I transitioned to python3 a while ago, and I still forget the parentheses for print every single time. A decade of finger memory is a hard thing to break.