encoding and decoding repr'd version of strings

Daniel Parisien dan at eevolved.com
Mon Jun 3 14:37:34 EDT 2002

Gustavo Cordova wrote:

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

Valid suggestion, but it's a lot of overhead for naught (I just want to 
store escaped strings, not data of all types). It's also a little too 


More information about the Python-list mailing list