Itertools wishlists
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Mon Mar 14 14:46:30 EST 2005
Thank you for your answers, Raymond Hettinger.
>The options also suggest that the abstraction is not as basic or
universal as we would hope.<
I don't understand, but this is normal.
> ll = open("namefile").read().split()
> r = partition(map(float, ll), 4)
>If you need that to be flattened one level, it would have been better
to do all the splits at once:<
Uhm, my purpose was the opposite, as you can see from the alternative
version. It was an example of using partition(), that is kind of
opposite of flatten().
>Generalizing the two results, it may be fair to say that the desire to
flatten is a code smell indicating that structure is being
unnecessarily destroyed or that earlier processing introduced unwanted
structure.<
Probably for my programming style flatten() is useful, but this is a
very subjective thing (and I've already coded my flatten that I use not
much frequently, without the level parameter inspired by a similar
Matemathica one), I've also implemented little other things from the
Delphi and Logo language, for my own use in Python.
For me it's not easy to improve/extend Python, maybe I have to stop
trying it, and I have just to use this language as you people are
giving us...
Than you, a bearish hug,
Bearophile
More information about the Python-list
mailing list