I'm tracing a legacy project, and see the source code is doing this:
globals()['my-str']
I know we use global
keyword when we want to change the value for the global variable in a local scope.
But what does global()
do?
I'm tracing a legacy project, and see the source code is doing this:
globals()['my-str']
I know we use global
keyword when we want to change the value for the global variable in a local scope.
But what does global()
do?
You can use the python interperter or pydoc to help you answer questions about keywords and builtins
$> pydoc globals
output:
Help on built-in function globals in module __builtin__:
globals(...)
globals() -> dictionary
Return the dictionary containing the current scope's global variables.
(END)
edit: globals
is not a keyword, it is a builtin