encoding and decoding repr'd version of strings

Gustavo Cordova gcordova at hebmex.com
Mon Jun 3 19:53:54 CEST 2002


> 
> Hi 
> is there an codec that bundles with python so you can 
> transform strings into the repr'd (escaped) version and
> back? If not, how easy would it be to code? I don't want
> to use eval(...) because I don't trust the source of the 
> string and I might mistakenly eval an expression like "' 
> '*(2**30)" which would allocate about 1 GB of data (eek!)
> 
> Thanks,
> Dan
> 

I might be going out on a limb here, but how about using pickle
or cpickle?

-gustavo





More information about the Python-list mailing list