0

I'm sure someone has come across this before, but it was hard thinking of how to search for it.

Suppose I have a file generate_data.py and another plot_utils.py which contains a function for plotting this data.

Of note, generate_data.py takes a long time to run and I would like to only have to run it once. However, I haven't finished working out the kinks in plot_utils.py, so I have to run this a bunch of times.

It seems in spyder that when I run generate_data (be it in the current console or in a new dedicated python interpreter) that it doesn't allow me to modify plot_utils.py and call "from plot_utils import plotter" in the command line. -- I mean it doesn't have an error, but it's clear the changes haven't been made.

I guess I kind of want cell mode between different .py files.

EDIT: After being forced to formulate exactly what I want, I think I got around this by putting "from plot_utils import plotter" \n "plotter(foo)" inside a cell in generate_data.py. I am now wondering if there is a more elegant solution.

SECOND EDIT: actually the method mentioned above in the edit does not work as I said it did. Still looking for a method.

user3391229
  • 798
  • 9
  • 17
  • Possibly duplicate of: http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module – Roberto Jan 27 '15 at 23:29

1 Answers1

1

You need to reload it:

# Python 2.7
plotter = reload(plotter)

or

# Python 3.x
from imp import reload
plotter = reload(plotter)
Roberto
  • 2,696
  • 18
  • 31