33

Porting over code to python3 from python2 be like:
(Cakechat, in this case)

Day 0 of n of python 3 compatibility work:
This should be _easy_, just use six and do magic!

Day 1 of n:
Oh, true division is default instead of integer division, so I need to replace `/` with `//` in a few places.

Day 2 of n:
Oh, map in python2 behaves differently than map in python3, one returns a list, other an iterator. Time to replace it with `list(map())` then.

Day 3 of n:
Argh, lambdas don't evaluate automatically, time to fix that too.

Day 4 of n:
Why did I bother trying to port this code in the first place? It's been so long and I DON'T EVEN KNOW WHAT IS BROKEN BECAUSE THE STUFF RUNS WHEN I BREAKPOINT AND STEP THROUGH BUT NOT WHEN I RUN IT DIRECTLY?!

Day ??? of n:
[predicted]
*gives up*
I've had enough.

Comments
  • 2
    there is something called 2to3.py. saves a lot of trouble.
    other then that, you should really do a full rewrite using async await/yield instead of updating the code base blindly.
  • 1
    @magicMirror well,
    1. CakeChat's a neural net, not sure async/await would be useful. (https://GitHub.com/lukalabs/...)
    2. A lot of this stuff is not something you could lint for, like the integer division / true division change.
    3. My aim here is to make the code *also* run on python 3 without breaking compatibility to python 2, sorry if I wasn't so clear with that. 2to3's fixes don't look like they can help much either.

    As of right now, PR#10 successfully starts the flask server with the pretrained NN, but training is still broken.
  • 1
    Change items to iteritems or vice versa for dicts 😁
  • 0
    Haha, the whole “works when I debug but not when I run” situation happens with me as well but with Selenium. I figured it’s because the script might be running faster than elements are loaded into the DOM but even when I add “waits” or “threadsleeps”, it still happens occasionally that my script breaks when I run. Lol

    This relation feels good. Thanks stranger.
Add Comment