On 4/6/2022 2:23 PM, Jeff Edwards wrote:
I will say I think that last comment misses the point.  It’s true that environment variable boolean configuration is definitely common enough I wouldn’t balk at some normalized methods for handling it.  But, I think the point has been well made it’s an opinionated choice that Python can’t force on other languages/systems even if Python normalized to exactly one, and so it’s better your opinion on parsing be explicit, given the potential for interface confusion.

My point was: bool is not special in the world, and as simple as it is (it's just 2 values!), even its issues are complicated. Now imagine those issues for every other type that we (for some definition of "we") would like to see supported. But the conclusion is the same: it's going to require some explicit code to specify the many options. And I left it unsaid, but I think that should best be in an external library.

Eric

On Wed, Mar 30, 2022 at 8:14 AM Eric V. Smith <eric@trueblade.com> wrote:
On 3/30/2022 11:02 AM, Adrian Torres Justo wrote:
Fair enough, thanks for the explanation
...


There are a lot of ways to interpret "convert to bool" - should "yes" and "no" be converted? What about "1" and "0"? Or "001", or "-1"? What should happen to unrecognised values? What if the environment variable doesn't exist? It's not at all obvious to me that strtobool is the definitive way of doing this (quite apart from the fact that distutils will be getting removed from the stdlib in Python 3.12 - see https://peps.python.org/pep-0632/).

What is so special about *this particular way* that it's worth including in the stdlib? Particularly when it's so easy to write for yourself.

Also: what's so special about bool? Why not int, float, datetime, etc?

Eric


_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KHOTWD4ZWFCCZU6UW73RIZXWCMZGURPQ/
Code of Conduct: http://python.org/psf/codeofconduct/