Is there a Python module that already does this?
bkelley at wi.mit.edu
Wed Feb 6 16:31:11 CET 2002
>I need to convert a list into a list of characters.
>Any information would be appreciated.
It's an interesting problem. A particularly slow solution follows.
Interestingly, it purposely uses the maximum recursion error to keep
the code simpler and not have to do any type checking. Given this fact,
it's faster than I expected :)
def _delve(s, target):
"""(s, target)->recursively split elements of s and
append each element to the target list
Warning, purposely uses maximum recursions
for data in s:
# catch maximum recursion errors
# this occurs when trying to split a character
# string like "s"
"""(input)->recursively split input
('cat', 5, ['dog', [3, 3, 1]], 'zoo')
will reult in
('c', 'a', 't', 5, 'd', 'o', 'g', 3, 3, 1, 'z', 'o', 'o')
warning, purposely uses maximum recursions!
target = 
Whitehead Institute for Biomedical Research
More information about the Python-list