I am quite sure something like this must have been asked before but I couldn't word it properly to get to those questions. Here is my issue. Let's say I have a function called square
, which returns square value of a given number.
def square(number):
return number*number
I store square
function in main.py
file. So in the python shell, I import and run the function like this:
>>> from main import square
>>> square(5)
Output is obviously 25
in this case. However, when I make changes in the function, for the sake an example, let's say:
def square(number):
return number*number*2
and import and run in previously opened python shell again. The result remains the same (i.e. 25
). However, it should be 50
. The changes take effect if the close and reopen the python shell. Is there a way to overcome this without opening a new python shell everytime for testing. I have tested this in python 2.7.14
and 3.8.3
.