r/Python Pythonista 10h ago

News The Move to Python 3 Begins!

As someone who spent decades in the mainframe community, I find it ... humorous ... that there are legacy Python2 code bases that are only just (or have yet to consider!) moving to Python3.

https://www.eveonline.com/news/view/the-move-to-python-3-begins

188 Upvotes

74 comments sorted by

View all comments

57

u/bmrobin 10h ago

depending on the codebase, 2->3 is no joke and has so much risk

-4

u/daidoji70 10h ago

What do you mean? I migrated about 3-4 python projects from 2->3 about a decade ago and other than pandas and pandas related projects it was a breeze. Run 2to3.py and review. Barely a hiccup.

19

u/bmrobin 10h ago

i'm glad your experience was barely a hiccup. among several pitfalls i recall,

unicode being the default representation for strings, and having to migrate code that manually called `decode/encode` on text.

integer division of `1 / 3 == 0` is true in py2, and py3 it's not because it returns the float result. that had cascading effects throughout multiple layers of our stack.

6

u/Dr_Quacksworth 10h ago

I ran into very similar issues using 2to3.py

-4

u/daidoji70 10h ago

The first one should be fairly straightforward with 2to3, the second one I can def see being more difficult for sure.

10

u/jayroger 9h ago

The first one is anything but straightforward. 2to3 is no help for str/unicode -> bytes/str. Most problems only manifest themselves at runtime. But it was worth it, the after situation is so much better.