89DEVs

Python locals() function

overview of locals()

The locals() function returns a dictionary containing all local variables, classes and methods. The same dictionary can be shown for the global scope using the globals() function.

demonstration of locals()

The locals() method returns the local symbol table, which stores all information related to the local scope. # demonstration of locals() locals() The locals() method is called and the dictionary of the current local symbol table is shown. {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': }

syntax of locals()

The syntax of locals() is: locals()

arguments of locals()

The locals() function doesn't accept any arguments.

return value of locals()

The locals() function returns the dictionary of the current local symbol table containing all local variables, classes and methods.

                
        

Summary


Click to jump to section