You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/12/16 16:10:33 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #6819: [AIRFLOW-6257] Docs: improve Concepts/Additional Functionalities/Variables sections

kaxil commented on a change in pull request #6819: [AIRFLOW-6257] Docs: improve Concepts/Additional Functionalities/Variables sections
URL: https://github.com/apache/airflow/pull/6819#discussion_r358321499
 
 

 ##########
 File path: docs/concepts.rst
 ##########
 @@ -602,6 +611,16 @@ as such. The third call uses the ``default_var`` parameter with the value
 isn't defined. The get function will throw a ``KeyError`` if the variable
 doesn't exist and no default is provided.
 
+You can use the ``default_var`` argument to make sure of not overwriting
+an exsisting Variable key :
+
+.. code:: python
+
+    from airflow.models import Variable
+    variable = Variable.get("foo", default_var=None)
+    if variable is None:
+        Variable.set("foo", 5)
+
 
 Review comment:
   This is not needed and does not provide any new information that is not covered in the above examples

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services