4 ms·
It makes me a little sad to see him write Python 2 code. There's only 18 month of Python 2 left.
by mrweasel 8y ago
It makes me a little sad to see him write Python 2 code. There's only 18 month of Python 2 left.
- starbugs 8y agoThat's what all of us oldies do. We can't get used to the hip new stuff so quickly ;)
- welder 8y agoMost of the time you're writing Python3 code and you don't even know it... try changing #!/usr/bin/env python to #!/usr/bin/env python3 I bet your Python2 script will run on Python3.
- ageofwant 8y agoAnd then there is 2to3, which has not failed me once.
- matmann2001 8y agoIt might be interesting as a learning exercise but there's a lot of gotchas in running 2 as 3. Besides the obvious things like print, which will just cause an error, there's behavioral changes, like with division and range, that may introduce more insideous bugs. Better to read up on the difference first and use a tool.
- flyingfences 8y agoThe "hip new stuff" is, in this case, already ten years old, though.
- js2 8y agoI know you’re being sarcastic but anyway: I’m an oldie I guess as I started with Python 1.5.2 and I’ve been using 2.7 now as long as I can remember. But I had a new project last month so I used Python 3. There was basically nothing to learn. I mean, print is a function and classes don’t need to inherit from object and you’re like 99% of the way there. Learn and adopt new 3 functionally at your leisure. I’m honestly having no trouble switching between 2 and 3 and I’ve converted all my 2 code to be syntactically compatible with 3.
- alain_gilbert 8y agoUh-oh, and well, integer division now gives float $ python3 >>> 1/2 0.5 VS $ python2.7 >>> 1/2 0 which can cause a great load of bugs if you're just porting some existing code.
- js2 8y agoTrue, but I can’t recall a single time I wanted the integer division behavior of Python 2.
- aldanor 8y agoAnd strings are now strings, surprisingly, and not bytes...
- js2 8y agoWhy do you say surprisingly? I've been aware of the bytes/string split for a long time since it's probably Python 3's most prominent change, so I certainly wasn't surprised by it. The surprising part for me (after having read complaints about this change over the years) is that I haven't had any trouble with it.
- deleted 8y ago[deleted]
- yeukhon 8y agoThe sad thing is he didn’t use open in context manager....
- Phrodo_00 8y agoHe should've also used load instead of loads, although in this case is not such a big problem (if he closed the file) because everything is getting loaded in memory anyway.
- yeukhon 8y agoRight. My problem is he was trying to show off his skill (he emphasized "engineer" at the beginning of his video) so he could troll the scammer. In that case, at least know how to write proper code. Even intro to Python writes with "with".