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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
P.Escondido
  • 3,373
  • 6
  • 23
  • 29

1 Answers1

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.

jayelm
  • 7,236
  • 5
  • 43
  • 61
  • 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? – P.Escondido Jan 17 '14 at 08:00
  • 1
    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: http://stackoverflow.com/questions/19329601/interactive-shell-debugging-with-pycharm – jayelm Jan 17 '14 at 08:06