You can use the getattr()
function to get arbitrary attributes named in a variable from the module:
import myDict
list_name = 'wallet'
print getattr(myDict, list_name)
Simply use raw_input()
to ask the user for either wallet
or numbers
and you are set!
import myDict
list_name = raw_input('wallet or numbers? ')
print getattr(myDict, list_name)
You may want to use a try:
/except AttributeError:
to catch mistakes:
list_name = raw_input('wallet or numbers? ')
try:
print getattr(myDict, list_name)
except AttributeError:
print "Sorry, no such list"