python and macros (again) [Was: python3: 'where' keyword]

Peter Maas peter at somewhere.com
Fri Jan 14 07:11:41 EST 2005


Craig Ringer schrieb:
> And then we have iteration ....
> 
> (generator expressions, list comprehensions, for loops, ...?) over
> (sequences, iterators, generators)

Just sequences and iterators. Generators are functions which return
iterators. Sequences and iterators provide two ways to build
containers.

My use cases:

finite, can be defined by enumeration: use sequence
infinite, must be defined algorithmically: use iterator

generator: neat way to produce an iterator, can also be viewed as
a persistent function call (better than static local variables).

Once defined, sequences and iterators have nearly the same interface.
To have list comprehensions but no equivalent for iterators would
be strange.

> I happen to be extremely fond of the flexibility this provides, but one
> obvious way to do it there is not.

Development of the language, backward compatibility and obviousness
are diverging goals. You can't satisfy them all at the same time.

And goals provide a direction but are rarely reached. :)

-- 
-------------------------------------------------------------------
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------



More information about the Python-list mailing list