I have an objectdatawhich has fields:link_1,name_link_1,link_2,name_link_2etc

How can I get them all through the loop?


array_links= []
for i in range(0.5):
  #array_local= [data.globals()['name_link_' + i], data.globals()['link_' + i]]
  array_local= [data.eval('name_link_' + i),data.eval('link_' + i)]

Have you tried using lists instead of numbered fields?

insolor2022-01-14 09:17:50

print(dir(data)) first try

CrazyElf2022-01-14 09:22:21

@insolor correct point, but this list is taken from a third-party API, the jamb is on their side. I have to do(

artemgh2022-01-14 09:22:21

@CrazyElf I will output the object and see those fields, for what?

artemgh2022-01-14 09:22:55

@artemgh Well basically you can iterate over this list dir(data). You just need to see if these fields are there and whether there is a lot of extra stuff.

CrazyElf2022-01-14 09:24:00