Posts

Showing posts with the label namespace in python global namespace

Global Namespace

Image
The  global  namespace contains any  names   defined  at the  position  of the main  program . Namespace in Python creates the  global  namespace when the main  program   body  starts, and it remains in  actuality  until the  practitioner  terminates. Rigorously   speaking , this may not  be  the  only   global  namespace that exists. The  practitioner   also  creates a  global  namespace for any module that your  program  loads with the  import   statement . I am just curious, I just recently learned that the Python built-in, global, and local namespace that the interpreter uses to reference objects is basically a Python dictionary. I am curious as to why when the  global()  function is called, the dictionary prints the variable objects in a string but the objects in functions defined refer to a hardware memory address? For example- This script: print ( "Inital global namespace:" ) print ( globals ()) my_var = "This is a variable." print ( "Updated global