[Tutor] Addressing a variable whose name is the value of a string

Bob Gailer bgailer at alum.rpi.edu
Mon Apr 9 01:11:12 CEST 2007


Andreas Pfrengle wrote:
> [snip]

> looks good if I'm happy with my values inside mydict and don't want to 
> have sth. like x=5 in the end. But since 'x' is the name of a database 
> field (I simplified it here for an example), I still see no way around 
> the exec, so I can change the content of the x-field (consider the 
> content of the var-field as a vector to the corresponding field that 
> needs a change, x in the example).
> If this is still possible with a dict, I still don't see it (sorry), 
> but it would surely be more elegant than an exec-solution, since I 
> don't need security checks for the string that is saved, before 
> executing it.
I'd love to help, but am confused. If your code (at least the relevant 
part) is of reasonable size, would you post it?

Or at least some pseudo-code so I can follow your algorithm?

-- 
Bob Gailer
510-978-4454



More information about the Tutor mailing list