4 ms·
Lots of library maintainers can't be arsed to put parentheses around their print statements (and perform the occasional slight change to other behaviors), or to
by enkiv2 10y ago
Lots of library maintainers can't be arsed to put parentheses around their print statements (and perform the occasional slight change to other behaviors), or to run any of the automated tools that perform these compatibility-preserving changes. As a result, libraries maintained by these stubborn lazy people are not usable on python3, which makes beginners (who don't have a clear understanding of how these libraries are written and how easy it would be for them to perform the conversions themselves, because they still believe that "professionals" have some magic power other than the willingness to be persistent) wary of doing anything in python3.
It's very straightforward to write code that works in python 2 and python 3, and anyone learning python for the first time should be learning to write in that way. Ultimately, many of the compatibility changes are making things that have long been possible but considered poor style / bad habits no longer possible when doing so made the language easier to understand and behaviors more predictable (think print statement vs print function), or streamlining things that were originally bolted-on (think unicode).
- trcollinson 10y agoFull disclosure: I do not work in Python. However, I found your explanation really enlightening and it brings up a further question. If there are tools that would make these libraries better in some automated fashion, would there be an opportunity for an open source project to basically go through all of the libraries and check them for compatibility and then run the automation to try to upgrade them and submit pull requests for the outcome if it turned the project from incompatible to compatible? I live over in the Ruby and JavaScript realm of things. I can imagine running through every project on Ruby Gems or on NPM and through it would be a monstrous undertaking it would be useful to the community and to the projects themselves. Would this be possible on the Python side of things as well?
- enkiv2 10y agoA properly written python2 module will already be python3 compatible, in most cases. Occasionally, modules that violate existing best practices will do so in ways that limit python3 compatibility. They can be fixed with automated tools that ship with python. Package systems like pip have separate repositories for python2 and python3, and you can have both python2 and python3 installed along with pip3 and pip2, and a whole package set for each; a package that is not compatible with python3 won't be available from pip3. But, most packages were already compatible, and those that weren't have had many years to become compatible. Any python package that currently doesn't support python3 is either no longer being maintained or is acting as a political statement.
- tedmiston 10y ago> Lots of library maintainers can't be arsed to put parentheses around their print statements Sorry, but this comment is really misinformed. Most libraries do not exactly have tons of print statements. Library compatibility across 2/3 has more to do with the changes to strings.
- enkiv2 10y agoIt's a slight overstatement for rhetorical purposes. Supporting python3 is not a difficult problem even for large libraries with single maintainers; as I noted, automatic translation tools exist.
- tedmiston 10y agoIt's not really an overstatement as much as completely incorrect and misleading. Yes, 2to3, tox, etc exist, but of course in practice it's not necessarily that simple, even for bigger libraries. Take Airbnb's Airflow for example.
- enkiv2 10y agoAirbnb hasn't been around for all that long. Why didn't they write their library with python3 support in the first place? Yes, there are some python2 features that work differently in python3. But python3 has existed for a decade now, and there aren't real benefits to using forward-incompatible methods. Writing code that won't work in both is a mistake.