Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

stupid python question

Name: beginner 2010-08-25 11:06

Simple (I think?) Python problem here.

Is there anyway to use a string the user inputs as a variable?

e.g., if a user inputs "var1", how can I then go and call something(var1) without using if/elif.

Here is a longer example of what I want to do; get the user to define "NATION" and then assign a random name from that nation's set of names.

http://pastebin.com/cHL9NqqX

The actual thing I'm writing will have tons of nationalities, so I'm hoping to skip the huge elif tree that would result.

Name: Anonymous 2010-08-25 12:55

Saw this thread on /g/ an hour ago or so, everyone there were trying to sound like an expert and said ``Yeah definitely use raw_input, input is unsafe as it tries to run the command the user inputs'' instead of reading the OP.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List