DEV Community

Discussion on: Converting a csv writer from Python 2 to Python 3

Collapse
 
rrampage profile image
Raunak Ramakrishnan

Did you try 2to3 on the Python 2 file? I'm interested in knowing what output it gave. I have heard quite a few problems are identified on a single run of the script.

Collapse
 
thejessleigh profile image
jess unrein

2to3 just identified the issues with print statements. Technically, opening a file in binary mode isn't a bug or unexpected behavior, based on the way I wrote the Python 2 file. But the way that binary mode works in 3, and the way that the Python 3 csv writer encodes strings under the hood created an unexpected interaction that broke forwards compatibility.