Reputation: 99418
I run my python script after launching Python environment in bash. Then I want to examine a variable defined in my script. But I cannot. I wonder how I can run the script in Python while still being able to examine the variables defined in the script after finish running? Note that I don't want to write the values of the variables to a file or stdout. Thanks!
>>> import myscript
>>> myvar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'myvar' is not defined
Upvotes: 1
Views: 94
Reputation: 805
You need to say that the variable is part of your import:
import myscript
myscript.myvar
or
from myscript import *
myvar
Upvotes: 3