Is there a boolean(somestring) equivalent of int(somestring).
tjreedy at udel.edu
Mon Apr 12 22:39:04 CEST 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
> >How can anyone argue that
> >bool('false') = True
> >is more natural (and what you would expect) than
> >bool('false') = False
I would not argue about what *you* would or should expect, since I know
nothing of your background and thought processes, but as for myself:
1. I am aware that the Boolean values, in themselves, are abstractions. In
applications, they can represent the two possible answers to *any* forced
dichotomy: nothing/something, 0/1, open/closed, up/down, inside/outside,
dead/alive, passive/active, off/on, default/marked, wrong/right,
isolated/connected, and so on, and, oh yes, when interpreted for logic,
2. I know Python to be a global algorithm language, and not just for
English speakers, even though the keywords and builtin names are English or
English-based. So I would not expect operators to be English-biased in
their operations on values (as opposed to names).
3. I know that the dichotomy chosen for bool(sequence/collection) is
empty/something, and that strings are a sequence of bytes.
Terry J. Reedy
More information about the Python-list