Re:JPMorgan still has its Python 2 issues
by isaac21259 on Friday February 05, 2021 @04:53AM
(#26034660)
Why doesn't the 2to3 tool that ships with python work for them? I rarely write python but I've had to convert from python 2 to 3 several times and it has always work fine. Are there gaps in 2to3 which I haven't encountered that can't be fixed?
[ Parent
| on HN ]
Re:JPMorgan still has its Python 2 issues
by eesmith on Saturday February 06, 2021 @07:54AM
(#26046199)
If there's a mix of byte and unicode strings then 2to3 won't work. Consider:
with open("a", "rb") as f:
with open("b", "w") as g:
g.write(">" + f.read(1))
There are also conversions in Python 2 between byte and string which aren't supported in Python 3: s = "123".encode("hex")
t = "abcd".decode("hex")