while true: !!!
Carsten Geckeler
nospam at no.spam
Mon Dec 18 17:32:23 EST 2000
On Mon, 18 Dec 2000, Steve Lamb wrote:
> On Mon, 18 Dec 2000 13:36:27 +0100 (CET), Carsten Geckeler <nospam at no.spam>
> wrote:
> >Anyway it's a very common idiom. But the point is that using true and false
> >would make the code more readable in cases where it's not clear, that the
> >value is used as a boolean value later. E.g:
>
> [Example of if conditions snipped]
>
> You're mixing examples. I doubt that anyone has a problem with storing a
> value in an appropriately named variable. However, how does that address
> having true equate to false? That would be the requirement of having "while
> true:" and then terminating the loop with assigning "true = 0" thus making
> that consition false. Meanwhile the very valid break would go unused for the
> exact purpose that it was designed for, breaking out of a loop.
Sorry, but that was not my point. Of course, defining true = 0 would be a
bad way of ending the loop. In case you use true and false variable,
those should be defined to 1 and 0 and never be changed. The break
statement is definetly the best way to terminate a loop. I just said that
`while true' would be more readable and clear than `while 1'. By the way,
explain a newbie that -1 is true. ;)
Cheers, Carsten
--
Carsten Geckeler: carsten dot geckeler at gmx dot de
To get proper email-address replace `dot' and `at' by the corresponding symbols.
More information about the Python-list
mailing list