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

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -