I'm having problems with trying to get python to recognize the latest file.
Take this simple function for example
def printme( str ):
"This prints a passed string into this function"
print(str)
return
I then navigate to the directory and did an
import printme
Ran printme printme.printme("Hello"). It works fine.
I then I updated the function to print Hi. I then remove the module using del printme
def printme( str ):
"This prints a passed string into this function"
print('Hi' + str)
return
Why doesn't python print "Hi" in front of the string?
1 Answer 1
The contents of the module have already been loaded. Modules aren't loaded again and again every time they are imported. (That would be quite wasteful.) To load the module again, try
reload(printme)
answered Sep 9, 2014 at 15:28
khelwood
59.7k14 gold badges91 silver badges116 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
chepner
Related,
printme was not the only reference to the module. If you had also run import sys; del sys.modules['printme'], then the module would have been removed from memory, and import printme would have actually reloaded the module.lang-py