Wishlist item: itertools.flatten
Ville Vainio
ville at spammers.com
Fri Mar 11 06:32:45 EST 2005
For quick-and-dirty stuff, it's often convenient to flatten a sequence
(which perl does, surprise surprise, by default):
[1,2,[3,"hello",[[4]]]] ->
[1, 2, 3, 'hello', 4]
One such implementation is at
http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348
but something like this would be handy in itertools as well.
It seems trivial, but I managed to screw up several times when trying
to produce my own implementation (infinite recursion).
--
Ville Vainio http://tinyurl.com/2prnb
More information about the Python-list
mailing list