Load / Reload module
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Feb 4 04:43:58 EST 2009
Marius Butuc wrote:
> I want do declare some classes (classes.py) in an external editor,
> than import the file and use the classes. After I change the file, I
> want to reload the definitions w/o leaving the interactive
> interpreter.
>
> So far I have tried
> - import classes # doesn't import my classes
Use this and refer to the class from the imported module.
import classes
instance = classes.SomeClass()
...
reload(classes)
instance = classes.SomeClass()
This is by far the best way, but if you _must_,
from classes import *
instance = SomeClass()
...
reload(classes)
from classes import *
instance = SomeClass()
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list