asmeurer / blog

My blog
https://www.asmeurer.com/blog/
8 stars 2 forks source link

Moving Away from Python 2 | Aaron Meurer's Blog #10

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Moving Away from Python 2 | Aaron Meurer's Blog

https://asmeurer.com/blog/posts/moving-away-from-python-2/

asmeurer commented 3 years ago

To comment on this post, click on "Sign in with GitHub" below. If you don't want to authorize the Utterances bot, you can go to the GitHub issues page for this post and comment there.

asmeurer commented 3 years ago

These are the original comments on this post that were made when this blog used the Disqus blog system.

Comment from Nick Walter on 2016-05-20 16:16:54+00:00:

Thanks for writing this. I'm about to make a python course and was trying to decide between 2 or 3. I choose 3 and this just confirms more that it was probably the right decision.

Replies:

Comment from Sebastian Raschka on 2016-05-26 15:28:45+00:00:

I usually try to make my code compatible to both 2.7 and >3.4 to be useful to "most" people. Most of the bigger scientific projects do that at the moment, but yeah, ensuring 2.7 compatibility is an extra inconvenience (for me) :P. I am looking forward not to worry about 2.7 anymore (like most people don't worry about 2.6 anymore) :)

Comment from Peter Shinners on 2016-05-20 17:10:49+00:00:

I hope this forces the inevitable Python 2.8 to release sooner than later. Many want it, but nobody's been pushed far enough to actually go through with it.

Replies:

Comment from Michael Blume on 2016-05-21 05:39:22+00:00:

https://www.python.org/dev/...

Comment from SebastianBassi on 2016-05-20 18:35:42+00:00:

Python 3 not being backward compatible with Python 2 made it fail.

Replies:

Comment from gamesbook on 2016-05-26 15:23:54+00:00:

A fairly meaningless comment - unless this is a genuine prediction of the future?!

Comment from Marcos on 2016-05-20 18:51:27+00:00:

Maybe python3 needs a print statement.... That would motivate me to move...

Replies:

Comment from Dan Wolf on 2016-05-20 19:19:18+00:00:

I'm not meaning to be snarky, but I am legitimately curious as to what annoys you. Is it that your fingers are just programmed to not hit parentheses? Or is it that you like the aesthetics of a keyword over a function? To me it seems unimportant, but I can understand both the aesthetic argument as well as the opposite (that less keywords is simpler).

Replies:

Comment from Marcos on 2016-05-20 21:41:04+00:00:

when using python for debugging, for example
or if I have a variable somewhere in my code
I have to type print then ( then END then )

it really annoys.

I know the advantages of the print function. But at least to my habits typing, it annoys.
And really, from __past__ import print_statement would not be the end of the world.

how often does one *REALY* need to change the behavour of the print function ?

Replies:

Comment from asmeurer on 2016-05-21 01:01:05+00:00:

I somewhat agree with you. Changing print has always felt like a huge impediment to people transitioning to Python 3, for relatively little gain. I also feel that the "you can now overwrite 'print'" is a stupid argument, which should never have been made. Overwriting builtin functions is generally an antipattern (unless it's a method name).

The real reason to change print to a function is that, syntactically, the print statement was a wart on the language. It was the only place in the language where a trailing comma was syntactically significant (think about that for a moment). The syntax to print to a file was obscure and difficult to remember. And (and I literally just learned about this), it has some weird rules for when it does and doesn't print a space before objects.

print() the function just works like every other function in Python. You call it, and it prints its arguments. If you want to customize that behavior there are keyword arguments. I don't have any pedagogical experience, but I suspect this consistency helps people who are new to the language.

As to habits, well, if you're using Python, you're probably typing a lot of parentheses anyway. It actually ends up being not too bad (but I'm a fast typer, so maybe I'm biased).

Replies:

Comment from Noumenon72 on 2016-05-21 00:50:31+00:00:

I learned Python 3 before Python 2, so I was programmed for parentheses, but once I had to use Python 2 for a class on a virtual machine. Ever since, *every* time I have to type those parentheses, I get annoyed at the stupid regression. Parenthesis-less print is one of my favorite things about Groovy. It would be a major plus for making Python feel easy and modern.

Replies:

Comment from Dan Wolf on 2016-05-21 01:22:52+00:00:

I guess I can see that. To me it seems fairly unimportant, but then the only language I've used without them on the print was classic VBscript which nobody compliments, of course. Perhaps I'd really enjoy them.

Comment from Dan Wolf on 2016-05-20 19:16:51+00:00:

I have seen pretty good Python 3 support. Since coming to Python a year and a half ago, I don't believe I've had much disappointment with needing a Python 2 library. I wrote all my code in Python 3. Sometimes old examples are annoying, and it's annoying when a respectable blogger writes example code with Python 2, but I've been able to succeed by writing off the few Python 2-only libraries I come across as "abandoned" for now even if they might technically be getting commits. I think the worst scenario was for data scientists and professors, but I think they's changing too. I really enjoy 3, and when I notice something wouldn't have been possible as simply in 2, I'm always surprised by the holdouts.

Comment from Ondřej Čertík on 2016-05-21 02:18:50+00:00:

Good article, I agree with pretty much everything. Except one thing:

> (keep in mind that you're using open source libraries without paying for them—the developers literally owe you nothing)

I would point out that even though users typically didn't pay for open source software using money, it is not true that developers do not owe the users anything. Because if developers didn't owe users anything, then we can literally remove sympy from pypi and github, destroy the website, remove the mailinglist and so on. And still sleep well at night. So in fact, we, as developers, owe users quite a bit. Users pay with their time and by them promoting the library to other people. Thus, developers get more users and ultimately also more developers. In return, developers owe the users a commitment, that the library will be maintained responsibly. It doesn't mean that users own my time. It doesn't mean that I *have* to spend my time fixing a particular bug. But it does mean that I will do my best, withing reasonable limits, to help (perhaps by directing the user to another developer who can help). It's an implicit agreement/contract --- i.e. I never signed up anywhere that I have to help, but I want my library to be used, and I want users to know that they will get help. Also, if developers start behaving that they don't owe anything, i.e. literally they stop caring about users, then users will stop using the library, or somebody will fork it and create a better community.

So yes, developers owe something. But you are right, that developers do not owe money nor time nor work, but they do owe good will, and at least enough time to execute on the good will (as I said, at least directing users in the right direction, or more if developers have time).

My other comment is that PEP 394 is a major mistake, as that makes all distributions (including Debian and Ubuntu) to still use Python 2 for `python`. They need to change that and make `python` to point to the latest version that the user installs (or let the user choose), but it should not point to Python 2.7 when 3.5 is installed.

Replies:

Comment from asmeurer on 2016-05-21 07:42:32+00:00:

Yes, you are right. I actually think that all people owe goodwill to all other people in all aspects of life. In that sentence, I meant "owe" strictly in the economic sense (no payment has been rendered, so no services are due). Hence my use of "literally." I don't think it's fair (economically) for users of open source to make demands on those who provide it. But at the same time, the reason to provide open source in the first place is that of goodwill, and you shouldn't break that goodwill, even if there is no economic cost to doing it. It is a bit paradoxical, especially if you think economics are the only reason for doing things. I could probably write a whole essay on "why I contribute to open source."

Now that you bring this up, this sentence doesn't sit well with me, because I actually dislike it when people take this attitude, mostly because it does lead to this confusion of economic "owing" and goodwill "owing." So I'm going to delete the "owe you" part completely, and make it clear that I am only talking about payment of money.

Replies:

Comment from Konrad Hinsen on 2016-05-21 16:53:05+00:00:

To fully appreciate Ondřej's comment, it helps to read David Graeber's book "Debt: The First 5000 Years". It explains very well how informal and imprecise debt between members of a community was the backbone of social relations before the invention of monetary economy, whose main innovation was to make debt precisely measurable. That also opened the door to the idea of paying back a debt exactly, with no obligation left. And that in turn made anonymous economic relations possible.

Your statement that OS developers owe nothing to their users is true in the sense of the formal monetary economy and the laws that are based on it. What Ondřej refers to is the informal imprecise debt implicit in all non-anonymous human relations, which is what OS communities are based on.

Ultimately, this whole discussion is about attributing technical debt in the OS universe. Everybody would like to default on his/her own technical debt and modernize one's code without the burden of maintaining compatibility. But everyone would also like their dependencies to remain stable, and thus their authors to invest the additional effort to maintain compatibility. What we see happening right now in the Python community is a transition. Initially, the Python core team and the authors of the next layer of core libraries assumed the technical debt of the 2->3 transition. Now that most of the big libraries have finished the move to 3, they decide that the various small players who are still in the Python 2 world are not worth supporting any more.

This is of course a very understandable decision from an economic point of view. Developer resources are limited, and need to be used wisely. But there is a hidden cost in terms of reputation. Many small projects will simply disappear because they don't have the means to move to Python 3. Their authors and users will be disappointed by the Python community, and probably move on elsewhere (assuming they find some good elsewhere). It's very hard to estimate how many people are concerned. They are not very visible individually, but their total number might well be large, in particular in the scientific user community, where lots of people work with highly specialized and scarcely maintained code.

Replies:

Comment from gamesbook on 2016-05-26 15:28:13+00:00:

Yes; any transition will cause a loss in support. Every "organisation" (in the broadest sense of the word) loses people when it changes its policies or products or service levels etc. etc. The one saving grace in the open source world is that if a project - however small - is crucial to someone somewhere, there is a good chance that maintenance/upgrades will be taken over. You may be surprised just how well the scientific user community (which is where I work) will be able to adapt to this change...

Comment from Brian Miller on 2016-05-21 02:47:06+00:00:

If the maintainers really wanted people to move to v3 as much as they suggested that they do, then "import ___ from __future__" would have never been allowed to happen.

Comment from Jim Karabatsos on 2016-05-21 07:00:48+00:00:

I would *love* to move off Python 2.7. I just need Google to support 3.x on Google App Engine...

Replies:

Comment from Fredrik J on 2016-05-22 14:06:28+00:00:

I've seen that Google do offer Python 3.4 in what they call the GAE flexible environment, which of course is beta. Anyone tried that out yet? Experiences?

https://cloud.google.com/ap...

Comment from Berker Peksag on 2016-05-21 21:06:29+00:00:

> It often feels like core Python itself doesn't really want people to use Python 3. It's little things, like docs links that redirect to Python 2 [...]

This is now done: https://github.com/python/p...

Comment from v@disqus on 2016-05-23 11:21:56+00:00:

Why should everybody stop supporting Python 2.7 by date X? If you don't want to support it, stop supporting it. It's as simple as that. Why wait for everybody else? I don't get it.