Live data from Hacker News

Code that will break in Python 4

astrofrog.github.io

51–60 of 237 posts

Re: Code that will break in Python 4

#51
I am reminded of the horrible hacks that got encoded in various http user-agent strings so that new versions of browsers would be identified as various other older browsers so that badly written sites would send them the right version of the site for the features that they supported.

Re: Code that will break in Python 4

#52
post #14

Maybe Python 4 will be properly compatible with Python 2?? Kidding. But more seriously, probably good advice. Isn't "explicit" one of the Pythonic mantras? But I'm wondering if any code written today really will survive until "Python 4"?

I would certainly hope code written today at least _could_ last until python 4. The idea that everything has to be rewritten just because of a language version bump is a flawed thought process IMO.

Re: Code that will break in Python 4

#53

I don't get it. When Py4 comes in sight they'll fix it probably so `six.PY3` is only True when using a Python3 interpreter and I guess they'll introduce a viariable `six.PY4`.

You misread the article (six.PY3 is already like that).

Re: Code that will break in Python 4

#59
post #36

No problem! I've already fixed it so that all my code is forward compatible with Python 7000, despite not knowing what any of the syntax or library changes are going to look like.

There is a difference between writing code that might break and code that is guaranteed to break. Badly written version checks are guaranteed to break.

Which is why GetVersionEx() on Windows will always tell you that you are running Windows 8, unless your application has a manifest entry indicating specifically that it is compatible with a higher version.

Microsoft thought there were too many broken version checks in the wild, so decided to hobble the version check function as a fix. I can understand why they did it.

Post reply on HN