Executing a string as python code

Laura Creighton lac at strakt.com
Wed Oct 24 15:44:08 CEST 2001


Two weekends ago I spent a very tedious Saturday converting a piece of
code which used value00 value01 value02 ... value99.  where every one
of those values were lists that were produced using an interesting
algorithm. I liked the algorithm just fine, but a) I had over 7000
record values I wanted to generate with it and b) what I wanted to do
with the results was use them as input for one of _my_ algorithms.  So
I changed every one of them to be value[n].  Why are you breaking the
generality of your solution for the somebody (most likely yourself)
who comes along later and wants to extend or use your code?  There is
nothing magical, scary, or dangerous about lists of lists, and you
don't have to print them out if you don't like the way they look.

Laura Creighton





More information about the Python-list mailing list