question about True values

Carl Banks pavlovevidence at gmail.com
Thu Oct 26 00:25:24 EDT 2006


John Coleman wrote:
> Paul Rubin wrote:
> > "John Coleman" <jcoleman at franciscan.edu> writes:
> > > > then "x == 3" is false, but "int(x) == 3" is true.
> > > But then why is 3.0 == 3 true? They are different types.
> >
> > The 3 gets converted to float, like when you say
> >
> >   x = 3.1 + 3
> >
> > the result is 6.1.
>
> Yes - it just seems that there isn't a principled reason for implicitly
> converting 3 to 3.0 in 3.0 == 3 but not implicitly converting "cat" to
> boolean in "cat" == true.

Because being true is not the same as equaling True.  == is a test for
equaling, not being.


Carl Banks




More information about the Python-list mailing list