On Tue, Feb 9, 2010 at 10:00 PM, David <ld...@gmx.net> wrote: > Hi guys, > > I just wrote this message, but after restarting ipython all worked fine. > How is it to be explained that I first had a namespace error which, after a > restart (and not merely a new "run Sande_celsius-main.py"), went away? I > mean, surely the namespace should not be impacted by ipython at all!?
Python caches modules (in sys.modules). When you run inside of ipython, you are not restarting the interpreter so you don't get a clean module cache. This has implications for multi-module development. Suppose you have # module.py animls = ['cat', 'dog' ] # note the misspelling # main.py import module print module.animals If you "run main.py" you will get a NameError and the erroneous module.py will be cached in the module cache. If you correct module.py and again "run main.py" you will get the same error because module.py has not been reloaded. A couple of work-arounds- - run main.py from a command line or some other way that gives it a fresh interpreter - from ipython command line, or in main.py import module reload(module) Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor