0

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?

0

1 Answer 1

4

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)
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.