"Ray Gibbon" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> e.g. 1
> |    while new_data = get_more_data(source):
> |        process_data(new_data)
>
> is obviously the sort of thing I'm missing, but it is not a general 
> solution
> because :-
>
> e.g. 2
> |    while new_data, environment = get_more_data(source):
> |        process_data(new_data, environment)
>
> is something I'm equally likely to want to do, but I can't express it's
> meaning.

The other problem with while loops, even if assignment were allowed, is 
that the loop stops on any null (False) value.  So you soon would need to 
have the assignment buried within a comparison expression, as in C.

> Before I resign myself to the inevitable, 'that's the way it is - get 
> used
> to it', I'd just like to scratch it once.  But, before I try walking on 
> very
> thin ice, I want to ask whether there are expectations of some future
> changes which address these issues?

As Jeremy already implicitly pointed out, for loops already address these 
issues by combining assignment and a stop test, with the stop test being 
for a StopIteration exception rather than a null value.  Separating data 
generation and validation from data processing is much cleaner.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to