4 ms·
> learning Python By any means, if you feel the urge, you really should help yourself and scratch that itch. I understand that for someone new to python (henc
by lloeki 15y ago
> learning Python
By any means, if you feel the urge, you really should help yourself and scratch that itch.
I understand that for someone new to python (hence lacking the knowledge to get what's different between 2 and 3) you might feel uneasy about it, but really you should not.
Just learn py2.7 (+ django if that's you want) now, and bulletproof your code by using u"", b"", .encode and .decode at the edge when needed, also 123L in your code, together with from __future__ import division, print_function, and whatnot. The remainder is mostly syntax (like except) or namespace (like http.server) changes and will get caught and thus easy to fix when you try to run in py3 (contrary to if you don't use u""/b"" as values can "move" through code and blow up in a completely unrelated area). I might be forgetting something, but that's the gist of it.
As for learning, really you will have zero trouble acclimating yourself to any breaking change py3 introduces. The trouble only lies in existing, 'legacy' code, not for the one you write from scratch straight in py2.7, and especially if you aim for compatibility with the provided forward-compatibility features of python.
- peteretep 15y agoThat's interesting and informative, thanks. The list you've given looks like a good start - is there a definitive list you'd recommend anywhere?
- lloeki 15y agoThere's the official "What's New in Python 3.x" release notes [0][1][2] and some IBM articles [3][4]. [0] http://docs.python.org/release/3.2.1/whatsnew/3.0.html http://docs.python.org/release/3.2.1/whatsnew/3.0.html [1] http://docs.python.org/release/3.2.1/whatsnew/3.1.html http://docs.python.org/release/3.2.1/whatsnew/3.1.html [2] http://docs.python.org/release/3.2.1/whatsnew/3.2.html http://docs.python.org/release/3.2.1/whatsnew/3.2.html [3] http://www.ibm.com/developerworks/linux/library/l-python3-1/ http://www.ibm.com/developerworks/linux/library/l-python3-1/ [4] http://www.ibm.com/developerworks/linux/library/l-python3-2/ http://www.ibm.com/developerworks/linux/library/l-python3-2/
- maaku 15y agoGreat post. A point I want to emphasize is that learning py2.7 is learning Python 3, if you are careful to pay attention to the recommended/pythonic way of doing things. For the most part Python 3 removes syntax and functionality that was long-since depreciated or at least strongly advised against.
- sirclueless 15y agoPerhaps, but the lack of bytestrings seems to be what bites everyone. It's the only "deep" change and it affects anyone who wants to slice raw bytes (which includes most web frameworks).
- koenigdavidmj 15y agoPython 3 has bytestrings. They look like this: b'foo' And you can slice them up as you wish.
- koenigdavidmj 15y agoPython 3 has bytestrings. They look like this: b'foo' And you can slice them up as you wish.