string to list? possible?

Erik Max Francis max at alcyone.com
Sun Jan 20 15:06:28 EST 2002


maximilianscherr wrote:

> i need to convert a string like "[1, 2, 3, 4]" to a list [1, 2, 3, 4].
> possible?

Yep:

Python 2.1.1 (#6, Sep  2 2001, 10:26:49) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> str([1, 2, 3, 4])
'[1, 2, 3, 4]'

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Laws are silent in time of war.
\__/ Cicero
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.



More information about the Python-list mailing list