42 ms·
One thing that confuses me about Python is just how many projects don't specify if the app is supposed to use 2 or 3, and the correct answer isn't 'either'. Che
by tibbon 7y ago
One thing that confuses me about Python is just how many projects don't specify if the app is supposed to use 2 or 3, and the correct answer isn't 'either'. Check out something from Github, only to find I actually do need Python 2.7 or something. Is it that Python developers assume everyone will just intuit the version, or is there a default?
- StavrosK 7y agoIt's usually specified in setup.py.
- toyg 7y agoRule of thumb is that no version == python2, either because it pre-dates 3 or because the developer's concept of python is "what happens when I type python at the shell" so it's still 2. It's often a big red flag about quality; competent Python developers find it natural to state py3 support upfront (or lack thereof) because they know it matters.
- ssully 7y agoI think your point about competency is the best point. Recently though, I have been running into more and more projects that don't specify the version and are built using Python 3. I also used your rule of thumb, so seeing this was kind of surprising. Wonder if it's just the mentality shift that Python3 == Default?
- BeetleB 7y agoEh. Disagree. For small projects on Github that are actively maintained, it's more likely to be Python 3 and not Python 2 if not explicitly stated. Newer developers for newer projects just don't care about Python 2.
- reilly3000 7y agoIf not otherwise specified, I just look for a `print` command and see if its formatted as print 'my string' indicating Python 2 or print('my string') indicating Python 3.
- tibbon 7y agoYea, that's what I've come around to. Thanks for confirming that's a good path.
- umvi 7y agoIf they are using PyPI, the project should be specifying which versions it supports in either setup.cfg or setup.py[1]. For example, I decided to only support Python3 going forward. I've had person once open a PR to add python2 support, but I politely declined[2]. As such, PyPI shows that only 3.5+ is supported[3]. [1] https://github.com/RPGillespie6/fastcov/blob/master/setup.cfg https://github.com/RPGillespie6/fastcov/blob/master/setup.cf... [2] https://github.com/RPGillespie6/fastcov/pull/11 https://github.com/RPGillespie6/fastcov/pull/11 [3] https://pypi.org/project/fastcov/ https://pypi.org/project/fastcov/
- MzHN 7y agoRecently I ran into a Python script on GitHub that I couldn't get to run on 2 _or_ 3. Both errors were familiar from earlier cases of trying to run with the wrong Python version, but I have no idea how the code managed to do that for both, and frankly it wasn't worth the effort to look into.