1

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
1
  • 1
    What do you mean by variable here? Are you referring to an environment variable? Commented Apr 27, 2014 at 16:45

1 Answer 1

3

You need to say that the variable is part of your import:

import myscript
myscript.myvar

or

from myscript import *
myvar
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.