2

After the Python script execution I want to play with the variables which I generated during the execution.

Like, for example, one can do in RStudio, or the standard Python interpreter console.

1 Answer 1

3

I'd say the most straightforward option is to use the Python shell to simply import the file where the variable definitions are stored.

For example, foo.py would be:

a = 1
b = 2

Then in the python shell running in the same directory:

>>> import foo # or, from foo import *
>>> foo.a
1
>>> foo.b
2
>>> foo.a + foo.b
3

If you import everything, you can use any functions/classes/etc. interactively as well.

Sign up to request clarification or add additional context in comments.

2 Comments

If I want to do it from PyCharm console, my file should be contained i the Console 'Working directory'. How do I change that directory?
I'm not familiar with PyCharm. Apparently all files in the current project are added to the path, so you can just import? Take a look here: stackoverflow.com/questions/19329601/…

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.