# Python variable scope

**URL:** <https://forum.inductiveautomation.com/t/python-variable-scope/19427>\
**Category:** Ignition\
**Tags:** ignition78\
**Created:** [August 28, 2018, 9:34am UTC](https://forum.inductiveautomation.com/t/python-variable-scope/19427 "2018-08-28T09:34:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 28, 2018, 9:34am UTC](https://forum.inductiveautomation.com/t/python-variable-scope/19427/1 "2018-08-28T09:34:30Z")

</div>

I want to declare a few global Python variables in my application on startup for use by various scripts. e.g.

> ip = ['10.11.31.19', '10.11.31.24', '10.11.31.29', '10.11.31.55']

and to be able to access these in button press events, etc.

Q1. Is the Client Startup Script the right place for these or what is the correct 'module level' to place these into?  
Q2. Do I need the 'global' syntax in declaration or use?

Many thanks.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 28, 2018, 12:03pm UTC](https://forum.inductiveautomation.com/t/python-variable-scope/19427/2 "2018-08-28T12:03:40Z")

</div>

Place that assignment in the top level of a project script. Then access it everywhere as `project.myGlobals.ip`.  
You can also assign an empty list in the project script, and [.append()](http://www.jython.org/docs/library/stdtypes.html#mutable-sequence-types) items to it from anywhere else. You just cannot assign directly to that name elsewhere. Not even with `global`.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 28, 2018, 1:48pm UTC](https://forum.inductiveautomation.com/t/python-variable-scope/19427/3 "2018-08-28T13:48:08Z")

</div>

Thank you for your prompt reply. I wouldn’t have guessed that.

I think I’m in business until the next gap in my knowledge is exposed.
