Implicit conversion to boolean in if and while statements

Ranting Rick rantingrickjohnson at gmail.com
Mon Jul 16 01:03:52 EDT 2012


On Jul 15, 11:20 pm, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:

> (It's not like explicit and implicit are distinct -- everything depends
> on something implicit, if only the meaning of the words you use to
> describe it.)
>
> It certainly doesn't mean that the semantics of Python the language must
> be written out explicitly every time you use each feature.

Of course not. Don't be ridiculous.

> for x in sequence: [...]

This syntax is explicit *enough*. We don't need to be any more
explicit.

But if you are going to argue that "if obj" is *explicit enough*, then
apply your argument consistently to "String"+1.75 also. Why must we be
explicit about string conversion BUT not boolean conversion? Can you
reduce this to the absurd? Or will you just choose to ignore this
valid point?



More information about the Python-list mailing list