Python globals() Function
Description
globals()The function returns all global variables at the current position as a dictionary.
Syntax
The syntax of the globals() function is:
globals()
Parameters
- None
Return Value
Returns a dictionary of global variables.
Examples
The following example demonstrates how to use globals():
>>>a='example'
>>> print(globals()) # The globals() function returns a dictionary of global variables, including all imported variables.
{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None, 'a': 'example', '__package__': None}
Python Built-in Functions