# Python 3 function node and global variables

**URL:** <https://discourse.nodered.org/t/python-3-function-node-and-global-variables/5327>\
**Category:** Dashboard\
**Created:** [30 November 2018 04:25 UTC](https://discourse.nodered.org/t/python-3-function-node-and-global-variables/5327 "2018-11-30T04:25:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristan](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@tristan](https://discourse.nodered.org/u/tristan)\
**Post date:** [30 November 2018 04:25 UTC](https://discourse.nodered.org/t/python-3-function-node-and-global-variables/5327/1 "2018-11-30T04:25:11Z")

</div>

I'm experimenting with the python 3 function node - trying to to pass global variables between two functions. There is no global.set() or global.get() exact equivalent in python. Just wondering what syntax could be try.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [30 November 2018 08:01 UTC](https://discourse.nodered.org/t/python-3-function-node-and-global-variables/5327/2 "2018-11-30T08:01:02Z")

</div>

For various reasons, I would like to recommend you to run the python code outside of Node-RED and communicate between them using MQTT. In this way you can still access variables in NR and have the benefit that your python code runs in one or more separate threads

---

<div class="post-metadata">

**Author:** ![tristan](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@tristan](https://discourse.nodered.org/u/tristan)\
**Post date:** [1 December 2018 02:40 UTC](https://discourse.nodered.org/t/python-3-function-node-and-global-variables/5327/3 "2018-12-01T02:40:43Z")

</div>

Thanks for what I'm sure is good advice. The python function nodes may not be ready for prime time. I have been a little apprehensive of writing functions in JS since I don't have a lot of experience with the language. But, there are plenty of examples for node-red and I'm sure if work on my curly brace anxiety I'll get the hang of this soon.
