Function Details: globals

Description


Returns the dictionary containing the current scope's global variables.


Extended Description


The globals() function returns a dictionary representing the current global symbol table. This is always the dictionary of the current module (inside a function or method, this is the module where it is defined, not the module from which it is called). Use locals() to get the local symbol table.


Read More about globals from Python Documentation

Function Signature


globals() -> dict

Module: builtins

Parameters



Return


Returns a dictionary representing the current global symbol table.


Return Type


dict

Output

Explanation

This example demonstrates how to use globals() to access and print global variables. It shows that newly defined variables are automatically added to the global namespace.