import question
Steven D. Majewski
sdm7g at Virginia.EDU
Tue Oct 16 11:36:12 EDT 2001
More information about the Python-list mailing list
Tue Oct 16 11:36:12 EDT 2001
- Previous message (by thread): [ANN] Narval 1.1
- Next message (by thread): import question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 16 Oct 2001, Vojin Jovanovic wrote: > Suppose I have a file foo.py file that contains a function > and now I do import foo. Then, I have my function available > in python. But let's suppose that I decide to change the function in foo.py > file > Why is it that doing import foo again doesn't load the new definition of > the function > which would be normal behavior in LISP for example? > Because of not having such behavior in Python one has to exit the program > and then > do import foo in order to load the new definition!? If you're going to compare Python statements to Lisp, Python's 'import' is closer to Lisp's 'require' than it is to 'load' : if it has already been loaded it won't do it twice. There is very little overhead to subsequent 'imports' : all it has to do is make the namespace available. You don't have to exit and restart the compiler (unless it's a module written in C as there is no 'unload' capability -- mainly because that's something that's not supported by the dynamic linking on all platforms.). Use "reload module", which will cause the file to be reloaded and reexecuted. If you did an import as "from foo import *" ,then you need to do: import foo # get foo into namespace reload foo # reload it from foo import * # until you do this, the names in this namespace # still point to the names in the old foo module. -- Steve Majewski
- Previous message (by thread): [ANN] Narval 1.1
- Next message (by thread): import question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list