Implicit conversion to boolean in if and while statements

Albert van der Horst albert at
Mon Jul 16 19:57:45 CEST 2012

In article <b2971c4d-0769-4d03-a7b6-c527629a85c1 at>,
Ranting Rick  <rantingrickjohnson at> wrote:

>We DON'T want Python to silently convert "cost" to a string. What we
>DO want is to force the author to use the str function thereby making
>the conversion explicit.

We do want Python to silently convert "cost" to a string in the
proper context.

cost= 3.75
print( cost )

>Same with converting objects to bools.

I think "if" is sufficient context to convert something to a boolean.
It now is a matter of good taste and what fits best in Python as a
whole. Nothing to be dogmatic about.

Groetjes Albert

Economic growth -- being exponential -- ultimately falters.
albert at spe&ar& &=n

More information about the Python-list mailing list