---
title: "How environment variables are passed in a Python script"
description: "Environment variables are accessed in Python scripts using os.environ['VARIABLENAME']. The example shows how to retrieve variables within a Toolkit Sampler Dataview script."
url: "https://docs.itrsgroup.com/docs/faq/geneos/360003410938-geneos-how-environment-variables-are-passed-in-a-python-script/index.html"
---
Use function `os.environ['VARIABLE_NAME']`.

Sample python script:

```
#!/usr/bin/python

import os
var = os.environ['VARIABLE_NAME']

print ('Column1, Column2')
print ('row1,' + var)
```

Toolkit Sampler:

![Toolkit sampler Python script](https://docscdn.itrsgroup.com/faq/images/geneos/toolkit-sampler-python.png)

![Toolkit VARIABLE_NAME function](https://docscdn.itrsgroup.com/faq/images/geneos/toolkit-VARIABLE_NAME.png)

Dataview:

![Toolkit Python dataview](https://docscdn.itrsgroup.com/faq/images/geneos/toolkit-python-dataview.png)


