Re: [Python-Dev] bool conversion wart?

2007-02-26 Thread Jordan Greenberg
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

Re: [Python-Dev] bool conversion wart?

2007-02-26 Thread Josiah Carlson
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

Re: [Python-Dev] bool conversion wart?

2007-02-25 Thread Greg Ewing
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

Re: [Python-Dev] bool conversion wart?

2007-02-24 Thread Guido van Rossum
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

Re: [Python-Dev] bool conversion wart?

2007-02-24 Thread Georg Brandl
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

Re: [Python-Dev] bool conversion wart?

2007-02-24 Thread skip
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

Re: [Python-Dev] bool conversion wart?

2007-02-24 Thread Guido van Rossum
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

Re: [Python-Dev] bool conversion wart?

2007-02-23 Thread Greg Ewing
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

Re: [Python-Dev] bool conversion wart?

2007-02-23 Thread Martin v. Löwis
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

Re: [Python-Dev] bool conversion wart?

2007-02-23 Thread Martin v. Löwis
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

Re: [Python-Dev] bool conversion wart?

2007-02-23 Thread Greg Ewing
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

Re: [Python-Dev] bool conversion wart?

2007-02-23 Thread Martin v. Löwis
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

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Mike Klaas
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({}) '{}'

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Neal Becker
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

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Mike Klaas
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))) ---

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Ben Wing
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

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Larry Hastings
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

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Stephen J. Turnbull
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

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Ron Adam
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:

Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Guido van Rossum
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