On Jan 9, 2008 10:42 AM, Lee Culver <[EMAIL PROTECTED]> wrote: > > > > > I don't know the answer to the original question, but this is not exactly > correct: > > > > > Another alternative would be to change your code to look like this: > > > > class MyClass(SomeNameSpace.IMyInterface): > > def SomeFunc(self): > > from mymod import myfunc > > myfunc() > > > > That way, the import gets re-run each time you run SomeFunc, and > > you'll always get the latest version of the module. > > > > This will not re-import mymod every time the function is run. Once you run > "from foo import bar" or "import foo" then the "foo" module is loaded into > python and will not be reloaded from python without an explicit call to the > reload function. For example, let's say you have the following code in > mymod.py: > > > > def foo(): > > print "called foo()" > > > > def bar(): > > print "called bar()" > > > > print "Loaded..." > > > > And then you run this code: > > def test1(): > > from mymod import foo > > foo() > > def test2(): > > from mymod import bar > > bar() > > > > test1() > > test2() > > > > import mymod > > mymod.foo() > > > > "Loaded…" will be printed only once, because the module is only loaded once, > and never reloaded. This is a very useful feature which Python has > supported for quite some time, allowing you to sprinkle "from foo import > blah" around your code, and if and only if you hit one of these will the > module be loaded, and it will only be loaded once. > > > > Back to the original question, are you saying that if you restart your C# > program that the changed "mymod" is not loaded properly, or are you > modifying the script while the C# program is running? > > > > -Lee >
I am modifying the script while the C# application is running. I did find one solution, which was similar to something Curt suggested. foreach (KeyValuePair<string, ScriptScope> item in ScriptDomainManager.CurrentManager.GetPublishedModules()) item.Value.Reload(); This reloaded the modules in the CurrentManager. I assume that once the Hosting APIs are completed (soon hopefully!!) this will be changed so I have an unloadable script scope which I can just recreate when I do my calls as necessary. Thanks slide _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com