[Tutor] Concatenating Strings into Variable Names?

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Feb 3 01:34:06 EST 2004


> You can test these out:
> 
> try:
> print eval('the_answer')
> except:
> "Invalid choice"

But using eval() on user input is potentially dangerous 
since it could be a malicious value. In this 
case because we add the "Choice" string etc its 
probably safe, but in general eval() is a risky choice.

Alan G.




More information about the Tutor mailing list