convert string to list

Jochen Hub jhub at
Wed Oct 13 16:49:27 CEST 2004

>> ["A","B","C"]
> You can use eval for this.  Better, you could simply pass your list as a
> series of arguments from bash:

I tried with eval...simply using


it didn't work :-(, I got the error message

   File "./", line 64, in ?
     print eval(sys.argv[1])
   File "<string>", line 0, in ?
NameError: name 'A' is not defined

> #!/bin/bash
> A B C

The problem is that I want to pass one or two lists to the script, so it 
should be able to distinguish between

thescript ["A","B"] ["C","D",E"]
thescript ["A","B","C"] ["D",E"]
thescript ["A","B","C","D",E"]

More information about the Python-list mailing list