I try to create an object by passing the variables, but it seems not work.
I put a simple example below to show what I want. Please help me to deal with this issue.
Successfully
temp = catalog.TEST
temp = catalog.PROD
Not works, it pass string "i" instead of the list element as attributes
lists = ['TEST,'PROD']
for i in lists:
temp = catalog.i
Complete code I'm using dremio-client this package (https://dremio-client.readthedocs.io/en/latest/readme.html)
import dremio_client as dc
mydremio = dc.init(os.getcwd() + '/.config')
catalog = mydremio.data
# TEST and PROD are the folders that exist in my dremio server
a = catalog.TEST
b = catalog.PROD
# Cannot pass the list element to object "catalog"
list = ["TEST","PROD"]
for i in list
temp = catalog.i
Thanks Pavel for the solution, but I have a one more complicated question.
list = ["TEST","TEST.DEMO"]
# what's work - directly declare
test = catalog.TEST.DEMO
# works for "TEST" not works for TEST.DEMO
for i in list:
temp = getattr(catalog, i)