0

I have a file which I am playing around with and defining functions, however, I have noticed a curious thing. When I define a new function in the script I then have to close the console before I can import the newly defined functions. When I don't close the console, I get the following error.

 Traceback (most recent call last):
 File "<input>", line 1, in <module>
 ImportError: cannot import name 'simple_mul'

simple_mul is my new function. What is the reason for this? Am I not saving the script correctly?

Stephen
  • 23
  • 4
  • Possible duplicate of [Reimport a module in python while interactive](https://stackoverflow.com/questions/1254370/reimport-a-module-in-python-while-interactive) – DYZ Aug 19 '17 at 00:55

1 Answers1

0

You're trying to hot-swap code and for that, you need an additional module to enable this feature such as https://github.com/hoh/reloadr or https://github.com/narfdotpl/hottie.

As mentioned in this article, this is a recurrent question in Python. I also encourage you to read: hot reloading / swapping with Python and Reloading module giving NameError: name 'reload' is not defined for more information

Stephane Paquet
  • 2,315
  • 27
  • 31