convert string to list

Michael Foord fuzzyman at
Fri Oct 15 01:30:56 CEST 2004

Jochen Hub <jhub at> wrote in message news:<ckj5ie$tra$1 at>...
> Hi,
> 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:
> #!/usr/bin/python
> import sys
> argument1 = sys.argv[1]
> thelist = ???(argument1)
> and then call the script from the bash like this
> ["A","B","C"]
> Thanks you,
> Jochen

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 mailing list