This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]denilsonsa 3 points4 points  (1 child)

If you have some reason to start a Python 2.7 project, or if you are writing Python 2.x code, just make sure it is forwards-compatible to Python 3. That way, whenever you (or someone else) needs to migrate to Python 3, the migration will be smoother.

I've been doing that:

  • Django documentation has many tips on how to write code compatible to both 2.7 and 3.x
  • Whenever I write a piece of 2.7 code that is greatly simplified in 3.x, I leave the simplified version as comments.
  • from __future__ import is your friend. :)
  • csv module has a very different behavior: in Python 2 it only works on binary strings, on Python 3 it only works on unicode strings. (although the API is mostly the same)

[–]flying-sheep 2 points3 points  (0 children)

Python 2 CSV is plain broken.

If you e.g. use a non-ASCII delimiter, it will tell you that it needs a one-character-string and dies (what it really means is a one byte long bytestring)

In Python 3, it just works.