Get array from variable name in Python -
pretty new python, , can't work out (or find) how check array based on variable name.
eg:
type = "world" world_arr = [] town_arr = [] #add array [type + '_arr'].append('test') <-- how?
do not variable names dynamically. it's major code smell. use dict.
lists = { 'world': [], 'town': [] } type = 'world' lists[type].append('test')
Comments
Post a Comment