Previous Lesson Complete and Continue  

Airflow Xcom Example |top| 〈2026〉

from airflow.operators.python import PythonOperator def push_func(ti): ti.xcom_push(key='result', value='hello_xcom')

1/4 Ever needed to pass a value from one Airflow task to another? → Use (Cross-Communication). Think of it as a mini shared dictionary for your DAG run. 🧠

extract >> process

Use return as a shortcut – return value auto-pushes to return_value key.

def pull_func(ti): value = ti.xcom_pull(task_ids='push_task', key='result') print(value) airflow xcom example

One of the most common questions when building DAGs is: 👉 "How do I pass data from one task to another?"

push = PythonOperator(task_id='push_task', python_callable=push_func) pull = PythonOperator(task_id='pull_task', python_callable=pull_func) from airflow

def auto_push(): return "auto_xcom" # automatically in XCom