dexdagr8
dexdagr8

Reputation: 337

Accessing Airflow Variable in List format

i have this Variable on Airflow

['item_1', 'item_2']

then i get the variable

my_var = Variable.get('my_var')

and then i try to loop it like this

for var in my_var:
    print(var)

it prints the character one by one.

My question is: how do i access the list value? without printing the character one by one

Upvotes: 3

Views: 6532

Answers (1)

shankshera
shankshera

Reputation: 985

You can store it as JSON string then use deserialize_json=True

my_var = Variable.get("my_var", deserialize_json=True)
first = my_var[0]

Upvotes: 6

Related Questions