Testing conditions.
Fredrik Lundh
fredrik at pythonware.com
Thu Feb 10 02:47:44 EST 2005
Ray Gibbon wrote:
> This is NOT another request for statements to be accepted as expressions for
> two reasons:-
> 1. I've seen enough arguments on the subject where I've found myself firmly
> on the anti change side.
> 2. I now realise that it might scratch the itch, but it would not cure it.
>
> 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.
that's spelled
for new_data, environment in get_data(source):
process_data(new_data, environment)
in Python. if you have existing get_first_data and get_more_data
functions, add a wrapper function:
def get_data(source):
data = get_first_data(source)
while data:
yield data
data = get_more_data(source)
</F>
More information about the Python-list
mailing list