0

I want to create variables that hold the values packet.{name of the variable}. For example, I want sectID to get the value of packet.sectID. I've tried:

lst = ['sectID','MP_Sector_ID']
for field in lst:
    globals()[field]=packet.field

but packet.field doesn't give me the right value. Also packet is a class.

1 Answers1

0
lst = ['sectID','MP_Sector_ID']
for field in lst_duplicates: 
    globals()[field] = getattr(packet, field)