This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aeros
Recipients aeros, benjamin.peterson, docs@python, pitrou, rhettinger, stutzbach
Date 2019-07-20.21:14:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1563657249.02.0.281282574451.issue37635@roundup.psfhosted.org>
In-reply-to
Content
>The named versions are just alternatives available for end-users

While it is true that the usage of 0,1,2 is more commonly used across the repository, the constants are used several times across Lib/_compression.py and Lib/_pyio.py. From my perspective, it looks like the locations which already used the integer values were just not updated rather than it being an intentional design decision.

However, if it is primarily targeted at the end-users, I would still recommend at least updating the tutorial and perhaps other IO documentation to use the constants. To any user unfamiliar with the integers, the constants convey their purpose far more explicitly, and I don't think anyone familiar with the integers would be confused by the constants. 

>The numbered forms also let us avoid a bunch of otherwise unnecessary imports (which affect >start-up time and occasionally create load order bootstrapping issues).

I can definitely understand this argument for anything that doesn't already import IO. It probably wouldn't be worthwhile to increase start times and introduce load order bugs. 

But for anything that already imports IO anyways, this seems like it would only serve to be a readability improvement without causing any change in functionality. This might not make a difference at all to developers who are used to using 0,1,2, but their purpose is not inherently obvious to anyone that isn't. 

This change would be in alignment with "Explicit is better than implicit". The purpose of the integers is defined only by implication based on tradition, whereas the constants explicitly define the purpose of the argument. 

A major advantage of Python over many existing languages is the emphasis on providing maximum readability. Sometimes functionality should be prioritized, such as in places where IO is not already imported. But in cases where there is no functionality cost, readability should be the priority. Even for non-public sections such as the tests, improved readability leads to easier maintenance and incorporation of new Python developers.
History
Date User Action Args
2019-07-20 21:14:09aerossetrecipients: + aeros, rhettinger, pitrou, benjamin.peterson, stutzbach, docs@python
2019-07-20 21:14:09aerossetmessageid: <1563657249.02.0.281282574451.issue37635@roundup.psfhosted.org>
2019-07-20 21:14:09aeroslinkissue37635 messages
2019-07-20 21:14:08aeroscreate