6 ms·
Automated Python 2 to 3 code translation
- mherrmann 9y agoI don't mean to be negative, but how is this better than just using the `2to3` tool that already ships with Python?
- maweki 9y agoThat's not negative. That's the first and possibly only question. 2to3 "works" on whole projects and I'm not sending my code whoknowswhere.
- CoffeeBob 9y agoIt's better for the people that operate the site because they get all of your Python code.
- deleted 9y ago[deleted]
- mathnode 9y agoBut this web-2to3 is monetised with ads. The python community didn't think of that.
- raverbashing 9y agoThey (the python community) doesn't require a library for left-padding. I don't think they will fall for this
- mathnode 9y agoEven the Jedi felt that burn.
- sajthom 9y agoI understand this is meant as a side-project for the author to learn new stuff. From his blog: "It’s an online tool that I built for myself, and I hope other people can get some use out of it, I hav ported a lot of code in pyhon2 to python3 and I thouhgt thatthis web can help other people and also, it was a good oportunity for my, because I learned javascript and bootstrap for do it."
- raverbashing 9y agoI guess this is a sample project, that looks like a good portfolio piece, but for real applications it has all the downsides of an online tool and none of the upsides I'll keep calling 2to3
- 4c2383f5c88e911 9y agoa = "test" if a < 1: print(a)
- anc84 9y agoWhat about it?
- PerryCox 9y agoIf you enter the code above into the website it responds with: maybe the code is wrong?
- anc84 9y agoIt does not do that for me, the Python 3 version appears with no changes.
- 4c2383f5c88e911 9y ago"test" < 1 is a TypeError in python3, and it works in python2 (returns False), it is part of the pitfalls of porting code to python 3.
- deleted 9y ago[deleted]
- tyingq 9y agoThere are some corner cases that run fine in python but trip up 2to3 tools, including this web based one. This code for example: print(set(x for x in range(2),))
- eesmith 9y ago"asdf".encode("hex") Is there a tool which knows to translate this to: import binascii binascii.b2a_hex(b"asdf") Even worse, if the string isn't known to be a byte string or ASCII unicode string, it's something like: import binascii binascii.b2a_hex(s.encode("ascii") if isinstance(s, str) else s)