Skip to main content
Version: 8.1

system.util.getGlobals

This function is used in Python Scripting.

Description​

This method returns a dictionary that provides access to the legacy global namespace. As of version 7.7.0, most new scripts use the modern style of scoping, which makes the 'global' keyword act very differently. Most importantly, the modern scoping rules mean that variables declared as 'global' are only global within that one module. The system.util.getGlobals() method can be used to interact with older scripts that used the old meaning of the 'global' keyword.

New in 8.1.0
The globals dictionary now persists across the lifetime of the JVM, and is accessible at system.util.globals. This means system.util.globals will work as an alternative to system.util.getGlobals. However, system.util.getGlobals is still the only option that will appear in the Designer's autocomplete feature.

Client Permission Restrictions​

This scripting function has no Client Permission restrictions.

Syntax​

system.util.getGlobals()

Parameters​

Nothing

Returns​

Dictionary[String, Any] - The global namespace, as a dictionary.

Scope​

Gateway, Vision Client, Perspective Session

Code Examples​

Example #1 - system.util.getGlobals
# Read and print out global variable 'foo'
print system.util.getGlobals()['foo']
Example #2 - system.util.globals
# Write value 'hello' to global variable 'foo'
system.util.getGlobals()['foo'] = 'hello'

Keywords​

system util getGlobals, util.getGlobals, util.globals