On Jul 3, 2008, at 11:21 AM, Stavros Korokithakis wrote:
That is quite a bit better than duplicating the assignment, but this version duplicates the check (or rather defers it from the "while <expression>" part to the "if" part). I am not sure that it is as elegant as the proposed syntax...
The style with the check "in the middle", however, is fully general: you can do different checks at different points to determine when to break or skip the rest of the indented suite; the "while <expr> as <var>:" form only handles a specific case (though common). The "while <expr> as <var>:" for has a certain level of attraction, because it does deal very well with a very common case, but I don't know that it would make that much difference in my code. (Of course, for the specific use case being used to seed this discussion, the fileinput module may be helpful.) -Fred -- Fred Drake <fdrake at acm.org>