Run a Python script from Python prompt such that variables are loaded into the interactive environment
Question: Say I have a (somewhat pointless) Python script

    
    
    #!/usr/bin/python
    
    a = 5
    

Is there a way to run this script from the interactive prompt such that after
running if I type `a` I get

    
    
    >>> a
    5
    

and not

    
    
    >>> a
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'a' is not defined
    

More generally, if my script calculates something through a series of steps,
is there a way to access that something after the script has finished (in the
same kind of manner).


Answer: Import it:

    
    
    from yourscriptname import a
    

Each and every `.py` file in python is a module, and you can simply import it.
If the file is called `foo.py`, import `foo`.

