split a string and build tuple

GrelEns grelens at NOSPAMyahoo.NOTNEEDEDfr
Thu Feb 5 21:58:02 CET 2004


i'm looking for a pythonic and obvious way to do the following :

having a string space separated like : s = "w1 w2 w3 w4 w5 w6 w7 w8..."
how to get : l = (('w1', 'w2', 'w3'), ('w4', 'w5', 'w6'), ('w7', 'w8', ...),
...) ?
(a kind of splitting and grouping in an elegant way)

i think that list comprehension or "zip" could maybe help but i just can't
get it work,


More information about the Python-list mailing list