Is there a boolean(somestring) equivalent of int(somestring).

Mel Wilson mwilson at the-wire.com
Mon Apr 12 11:00:36 EDT 2004


In article <mailman.533.1081738820.20120.python-list at python.org>,
"Vineet Jain" <vineet at eswap.com> wrote:
>Thanks for the code suggestion.
>
>>From what I've read, most people (including me) are attracted to Python
>because of how natural it is. Give that is a high priority for the language
>designers:
>
>How can anyone argue that
>
>bool('false') = True
>
>is more natural (and what you would expect) than
>
>bool('false') = False



    bool("False") == True

because "False" isn't a null string.


    eval ("False") == False

because False is the name of the object named False, and
eval exists in order to take strings and execute them as
Python code, which includes referring to named objects.

   What did "Vineet Jain" have for lunch?

        Regards.        Mel.



More information about the Python-list mailing list