How to parse a string completely into a list
Chris Rebert
clp at rebertia.com
Wed Sep 24 23:44:25 EDT 2008
On Wed, Sep 24, 2008 at 8:30 PM, <john.ford at colorado.edu> wrote:
> I want to take a long alpha-numeric string with \n and white-space and
> place ALL elements of the string (even individual parts of a long
> white-space) into separate list elements. The most common way I've
> seen this performed is with the split() function, however I don't
> believe that it has the power to do what I am looking for.
> Any suggestions?
> thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Could you please define exactly what you mean by "elements" of a string?
If you mean characters, then just use list():
>>> list(" \n \t abc")
[' ', ' ', '\n', ' ', '\t', ' ', 'a', 'b', 'c']
Regards,
Chris
--
Follow the path of the Iguana...
http://rebertia.com
More information about the Python-list
mailing list