Executing a string as python code

Richard Jones richard at bizarsoftware.com.au
Wed Oct 24 05:45:09 CEST 2001

On Wednesday 24 October 2001 13:30, Stephen Boulet wrote:
> Can someone tell me how to execute an arbitrary string as python code?
> I'm trying to make a bunch of lists named list00, list01, ..., to list99 (I
> don't want to make a single list of lists, since list00 is actually already
> a list of lists), and I thought doing this as a string would be the easiest
> way.
> I guess a dictionary with string keys and list values would be another way
> (maybe a better way).

Pretty much any time you're considering "execute an arbitrary string as 
python code", you're doing things the (hard|insecure) way.

Investigate using a dictionary.


More information about the Python-list mailing list