question about True values
Gabriel Genellina
gagsl-py at yahoo.com.ar
Fri Oct 27 23:02:50 EDT 2006
At Friday 27/10/2006 23:13, Steve Holden wrote:
>J. Clifford Dyer wrote:
> > the one thing that Ms. Creighton points out that I can't get past is
> > that Python, even with its bool type, *still* evaluates somethingness
> > and nothingness, and True and False are just numbers with hats on.
> >
> > >>> True + 3
> > 4
> > >>> bool(True-1)
> > False
> > >>> bool(True-2)
> > True
> > >>> (10 > 5) + (10 < 5)
> > 1
>Seems pretty clear to me that the situations you discuss above involve
>numeric coercions of a Boolean value.
A "true" Boolean value should not be coerced into any other thing.
True+1 is as meaningless as "A"+1, or even "1"+1. The fact is, bool
is just an integer in disguise.
I always regretted that Python just went mid-way moving onto a true
Boolean type; I'd prefer it to stay as it was before bool was introduced.
> > Python is not evaluating the truth of the matter, but, as Ms. Creighton
> > would say, the "somethingness" of that which 10 > 5 evaluates to. (1
> > aka True)
> >
> >>> type(10>5)
><type 'bool'>
> >>>
>>> bool.__mro__
(<type 'bool'>, <type 'int'>, <type 'object'>)
>It does seem that there is a specific type associated with the result of
>a comparison, even though you would really like to to be "a number with
>a hat on".
It *is* an integer with a hat on.
>>> isinstance(True,int)
True
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list
mailing list