Question regarding stdlib distutils strtobool behavior

Joseph Bane havocjoseph at gmail.com
Tue Aug 9 15:47:22 EDT 2016


On 8/9/16 1:42 PM, Terry Reedy wrote:
> On 8/9/2016 9:22 AM, Joseph Bane wrote:
>> Hello.
>>
>> It recently came to my attention that the strtobool function in the
>> standard library doesn't return Python native boolean values, but
>> rather returns integer 0 or 1:
>>
>> https://hg.python.org/cpython/file/3.5/Lib/distutils/util.py#l304
>>
>> I am curious why this is the defined behavior and whether anyone can
>> fill me in regarding this approach. For clarity, I would expect the
>> code to `return True` and `return False` rather than `return 1` and
>> `return 0`.
> 
> I am rather sure distutils predates 2.2 and the addition of bool.  Much
> code has been converted from 0/1 to False/True.  I don't know if this
> particular holdover is intentional -- fear of breaking something -- or
> oversight/inertia.
> 
> I searched the tracker for 'strtobool' in component 'distutiles', status
> "don't care", and there were no hits.  (Search is not perfect, though.)
> 
> 

Thanks for the legwork here! I have created the following issue after I
read this: http://bugs.python.org/issue27721

Hopefully it will get some more discussion going. Thanks also to Michael
Selik for his great advice in his last response! I think it's great
we're having such positive conversations!




More information about the Python-list mailing list