The locals() function returns the dictionary of all local variables in the current scope.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
def temp(arg):
a = 1
print (locals())
temp(5)
Output:
{'a': 1, 'arg': 5}
Syntax
locals()
Parameters
The method doesn’t take any parameters.
Return Value
It returns the dictionary of local variables.