In Spyder, my script seems to have no access to the variables that are currently in the workspace?
When I repeatedly run the following script:
try:
name
except NameError:
print('name is not defined')
name = 'hello'
Then 'name is not defined' is printed in the IPython console every time I execute the script. However, I can see the variable in the variable explorer, and I can access it in the IPython console.
This didn't use to be this way?!?!
I am running:
Python 3.7.3 [MSC v.1915 64 bit (AMD64)]
IPython 7.12.0
Spyder 4.0.4
To change that you need to go to the menu
Run > Configuration per file
and activate the option called Run in console's namespace instead of an empty one
.
Most helpful comment
To change that you need to go to the menu
and activate the option called
Run in console's namespace instead of an empty one
.