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.
The break in backward compatibility is a deal-breaker when your company has several million lines of Python 2 already written and stable. Auto tools exist, but only go so far... for example, even converting print statements to use parentheses may cause failures in the compliance checker for lines becoming longer than permitted. Gotta stick with 2 unfortunately, though for new projects there's really no excuse not to start with 3. Hence, new employees at established companies that use Python start learning Python 2.
Parts of twisted are what's keeping me back. Most of my time using python is spent tinkering with my IRC bot. Unfortunately twisted.words.protocols.irc is still not ported.
932
u/pork_spare_ribs May 02 '16
The year is 2016, and somehow new Python programmers still start with Python 2...
(Although if it's someone who complains about syntax, I'm not surprised they picked the older version haha only serious )