Guido van Rossum wrote:
How would this change be helpful? I'm utterly mystified by these
suggestions that bool would be more useful if it didn't behave like an
int in arithmetic.
I don't think anyones really saying it would be more useful, it
obviously wouldn't, since like Greg said, it
Jordan Greenberg [EMAIL PROTECTED] wrote:
Guido van Rossum wrote:
How would this change be helpful? I'm utterly mystified by these
suggestions that bool would be more useful if it didn't behave like an
int in arithmetic.
I don't think anyones really saying it would be more useful, it
Guido van Rossum wrote:
How would this change be helpful? I'm utterly mystified by these
suggestions that bool would be more useful if it didn't behave like an
int in arithmetic.
I think there's a desire by some people to get rid of
unnecessary conceptual baggage left over for historical
Can anyone who is in favor of changing this please come up with a spec
for the new bool() signature? What would you do for the most common
use case of bool(), which is converting an arbitrary value to its
Boolean equivalent without using an if test or the not not x hack?
--
--Guido van Rossum
Guido van Rossum schrieb:
Can anyone who is in favor of changing this please come up with a spec
for the new bool() signature? What would you do for the most common
use case of bool(), which is converting an arbitrary value to its
Boolean equivalent without using an if test or the not not x
Neal Except, all the numeric types do, including int, float, and
Neal complex. But not bool.
The fact that bool is a subclass of int is more historic than necessary. If
not for Python's long usage of 0 and 1 to be the canonical False and True, I
suspect that bool might have been
On 2/24/07, Georg Brandl [EMAIL PROTECTED] wrote:
Guido van Rossum schrieb:
Can anyone who is in favor of changing this please come up with a spec
for the new bool() signature? What would you do for the most common
use case of bool(), which is converting an arbitrary value to its
Boolean
Neal Becker wrote:
The fact that other numeric
types act this way leaves a reasonable expectation that bool will.
But bool isn't really a numeric type in the same way
that the others are. It's only a subtype of int for
historical reasons. If it had been a part of Python
from the beginning, it
Neal Becker schrieb:
Doesn't this seem a bit inconsisent?
Please don't ask such questions. Instead, formulate them as
I would have expected the result to be X instead. Why is
the result Y? (if that is actually the question you meant
to ask)
IOW, what does it help you if somebody answers yes to
Greg Ewing schrieb:
But bool isn't really a numeric type in the same way
that the others are. It's only a subtype of int for
historical reasons. If it had been a part of Python
from the beginning, it probably would have been a
separate type altogether.
Hmmm... is that something that should
Martin v. Löwis wrote:
One idiom that people use a lot is foo[b], where
b is a boolean.
Could that be addressed using the new __index__ mechanism?
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
Greg Ewing schrieb:
One idiom that people use a lot is foo[b], where
b is a boolean.
Could that be addressed using the new __index__ mechanism?
That would be possible, yes.
Martin
___
Python-Dev mailing list
Python-Dev@python.org
On 2/22/07, Neal Becker [EMAIL PROTECTED] wrote:
Well consider this:
str (4)
'4'
int(str (4))
4
str (False)
'False'
bool(str(False))
True
Doesn't this seem a bit inconsisent?
Virtually no python objects accept a stringified version of themselves
in their constructor:
str({})
'{}'
Mike Klaas wrote:
On 2/22/07, Neal Becker [EMAIL PROTECTED] wrote:
Well consider this:
str (4)
'4'
int(str (4))
4
str (False)
'False'
bool(str(False))
True
Doesn't this seem a bit inconsisent?
Virtually no python objects accept a stringified version of themselves
in their
On 2/22/07, Neal Becker [EMAIL PROTECTED] wrote:
Except, all the numeric types do, including int, float, and complex. But
not bool.
Oh?
In [5]: str(complex(1, 2))
Out[5]: '(1+2j)'
In [6]: complex(str(complex(1, 2)))
---
On 2/22/07, Neal Becker [EMAIL PROTECTED] wrote:
Mike Klaas wrote:
On 2/22/07, Neal Becker [EMAIL PROTECTED] wrote:
Well consider this:
str (4)
'4'
int(str (4))
4
str (False)
'False'
bool(str(False))
True
Doesn't this seem a bit inconsisent?
Virtually no python objects accept a
Neal Becker wrote:
Instead, bool fails in _the worst possible way_: it silently gives a
_wrong result_.
I disagree with the word fail there; Python is working correctly. The
behavior of converting expressions to a boolean is well-defined:
http://docs.python.org/ref/Booleans.html
Perhaps
Neal Becker writes:
Well consider this:
str (4)
'4'
int(str (4))
4
str (False)
'False'
bool(str(False))
True
Doesn't this seem a bit inconsisent?
The former case is a *conversion* from an expression that *does not*
have an interpretation in a numerical context to an
Larry Hastings wrote:
Neal Becker wrote:
Instead, bool fails in _the worst possible way_: it silently gives a
_wrong result_.
I disagree with the word fail there; Python is working correctly. The
behavior of converting expressions to a boolean is well-defined:
This won't change so just get used to it. Please move any further
discussion to c.l.py.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
20 matches
Mail list logo