while (a=b()) ...
scott cotton
scott at chronis.pobox.com
Sun May 9 15:50:47 EDT 1999
On 9 May 1999 19:14:10 GMT, Andrew Clover wrote:
>Nathan Clegg (nathan at islanddata.com) wrote:
>
>> The ideal, of course, would be:
>
>> while (c = curs.fetchone()): ...
>
>> That is my only complaint about python, that statements cannot be
>> expressions.
>
> I agree with the sentiment; I'd prefer a syntax like:
>
> while (c= curs.fetchone(); c!=None):
> ...
>
> Where a semicolon would throw away the value of the left expression (an
>assignment evaluating to nothing), then return the boolean expression on the
>right. By allowing expressions to be made up of multiple statements like
>this, it would be easy to write nice middle-test loops.
I'd like to third this opinion.
> Also I'd like a colon operator to return the left expression after evaluating
>and throwing away the right, so you could write something like:
>
> c= a+b: (a= 1; b= 2)
i don't see why you like this? what's wrong with a=1; b=2;
c=a+b?
scott
More information about the Python-list
mailing list