Broken pip
Michael F. Stemper
michael.stemper at gmail.com
Fri Aug 31 13:34:46 EDT 2018
On 2018-08-29 16:02, Thomas Jollans wrote:
> On 08/29/2018 09:05 PM, Michael F. Stemper wrote:
>>> Also, PLEASE use Python 3. Still using Python 2 today is like still
>>> using Windows XP in early 2013.
>> I'm using the default version for the current release of my
>> OS (Ubuntu 16.04 LTS):
>> My understanding is that when I get around to upgrading to 18.04 LTS,
>> python3 will be the default.
>>
>> Since I don't hard-code a version in any of my programs, but simply
>> write "#!/usr/bin/python", all of my programs will automatically change
>> to the new version then.
>
> No, actually.
>
> As I understand it, Ubuntu 18.04 LTS uses python2 a lot less, and I
> don't think it's included in the default install. However, it's still in
> main, the name of the package is still "python", and it's still required
> by some common software... (including the recommended personal backup
> tool, duplicity :-/)
Interesting. I based my statement on
<https://wiki.ubuntu.com/Python#Plans_for_18.04_LTS>, which says:
"Python 3 only on the default installs for desktop, server, [...]"
Since this says "plans", not "accomplishments", I searched further
and found
<https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes#Other_base_system_changes_since_16.04_LTS>
where they say: "Python 2 is no longer installed by default."
I'm having trouble parsing this. If it's not in the default
installation, I'm not sure how it can be required. Conversely, if
it's required, I'm not sure how it can be left out of the default
installation.
> In any case, as per PEP 394, /usr/bin/python continues to point to
> Python 2.7 (if installed), it it will likely remain that way for the
> foreseeable future. (including, presumably, Ubuntu 20.04 LTS)
>
> PEP 394: https://www.python.org/dev/peps/pep-0394/
Boy, that led me down any number of rabbit holes. :-> I spent most of
yesterday following where it led me. I'm not yet persuaded, but at least
I'm better aware of some of the issues.
>> If I was to change all of my programs to say "#!/usr/bin/python3", I'd
>> have a slight head-start. However, then I'd need to change them all
>> again when python 4 came out. And python 5.
>>
>> I prefer to maintain version independence, or at least to avoid
>> implementing version dependence.
>
> You should know that there were some (deliberate) incompatible changes
> (vastly for the better) in Python 3.0 (almost ten years ago). It's
> normally easy to port your code, and not too hard to write code that
> runs on both Python 2 and Python 3 if required, but in any case you have
> to do this consciously,
I definitely do that. I use "//" for integer division, I never use
either "print" or "print()". I'm not sophisticated enough to do version
sniffing or binary files or non-ASCII text.
Every time I change one of my modules, I run the test code under both
python and python3.
By PEP 394:
"One exception to this is scripts that are deliberately written to be
source compatible with both Python 2.x and 3.x. Such scripts may
continue to use python on their shebang line."
> As for the "Python 4 problem" – at the moment nobody knows whether there
> will even /be/ a Python 4.
For what it's worth,
<https://docs.python.org/3/howto/pyporting.html#use-feature-detection-instead-of-version-detection>
says:
"The problem with this code is what happens when Python 4 comes out?"
Anyhow, you've given me a lot to think about, for which I thank you.
--
Michael F. Stemper
Exodus 22:21
More information about the Python-list
mailing list