split

rzed Dick.Zantow at lexisnexis.com
Fri Aug 9 17:50:32 CEST 2002


"Seo Sanghyeon" <unendliche at hanmail.net> wrote in message
news:45e6545c.0208082006.71908e01 at posting.google.com...
> How can I split a sequence other than a string?
>
> >>> split([1,0,1,1,0,0,1,0], lambda x: x == 0)
> [[1], [1, 1], [1]]
>
> ----
> split=lambda q,p=lambda x:x==' ':[q[s+1:e] for s,e in zip(*[h+m+t
for h,t in
> [([-1],[]),([],[l for l in [len(q)]])] for m in [[i for i in
range(l) if p(q
> [i])]]]) if s+1!=e]

Took the words right out of my keyboard. There should be one obvious
way to do it, right?

Where has that Learn Most of Python in 21 Days for Dummies book got
to?

--
rzed





More information about the Python-list mailing list