split

Seo Sanghyeon unendliche at hanmail.net
Fri Aug 9 06:06:44 CEST 2002


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]



More information about the Python-list mailing list