On Sunday 27 March 2005 05:04 pm, Michael Spencer wrote:
> � >>> def group(src):
> � ... � � stack = []
> � ... � � srciter = iter(src)
> � ... � � for i in srciter:
> � ... � � � � if i == "/":
> � ... � � � � � � stack[-1].append(srciter.next())
> � ... � � � � else:
> � ... � � � � � � stack.append([i])
> � ... � � return stack

Very pretty:

group("AGC/C/TGA/T")
[['A'], ['G'], ['C', 'C', 'T'], ['G'], ['A', 'T']]


-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to