convert string to list
fuzzyman at gmail.com
Fri Oct 15 01:30:56 CEST 2004
Jochen Hub <jhub at gwdg.here_simple_one_dot.de> wrote in message news:<ckj5ie$tra$1 at gwdu112.gwdg.de>...
> I am a real beginner in Python and I was wondering if there is a way to
> convert a string (which contains a list) to a "real" list.
> I need this since I would like to give a list as an argument to my
> Python script from the bash:
> import sys
> argument1 = sys.argv
> thelist = ???(argument1)
> and then call the script from the bash like this
> thescript.py ["A","B","C"]
> Thanks you,
Other posters have mentioned difficulties with what the shell will do
to your command line. If you can get it as a single string - I've
written a module that will turn a string like that back into a list. I
use it for reading lists from config files. It will properly handle
the quotes etc.....
It's called listwuote and you can find it at
More information about the Python-list