Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Airflow Variable in List format

Tags:

python

airflow

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

like image 512
dexdagr8 Avatar asked Apr 28 '26 14:04

dexdagr8


1 Answers

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]
like image 140
shankshera Avatar answered May 01 '26 03:05

shankshera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!