# Defining Variables

You can define variables:

* Using `_export` parameter in YAML
* Starting a session with variables


## _export:

In a YAML file, the `_export:` directive defines variables. This is useful to load static configurations such as the host name of a database.

Limitation
Variable definitions cannot reference other variables. For example, defining a variable as `bar: "${foo}_suffix"` within `_export:` is not supported.

If a task has `_export` directive, the task and its children can use the variables because it defines variables in a scope. With following example, all tasks can use `foo=1` but only +step1 (and +analyze) can use `bar=`.


```yaml
_export:
  foo: 1

+prepare:
  py>: tasks.MyWorkflow.prepare

+analyze:
  _export:
    bar: 2

  +step1:
    py>: tasks.MyWorkflow.analyze_step1

+dump:
  py>: tasks.MyWorkflow.dump
```

## Starting a Session with Variables

You can set variables when you start a new workflow session.

To set variables

1. Use the `-p KEY=VALUE` multiple times.
For example:



```bash
$ td wf run -p my_var1=foo -p my_var2=abc
```