[IronPython] Clearing context

Tim Roberts timr at probo.com
Wed Jan 9 23:45:43 CET 2008


On Wed, 9 Jan 2008 09:49:29 -0800, "Curt Hagenlocher" 
<curt at hagenlocher.org> wrote:
> On Jan 9, 2008 9:42 AM, Lee Culver <leculver at microsoft.com> wrote:
>   
>> >
>>     
>>> >> 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.
>>     
>
> Poor wording on my part, sorry. What I should have said was that the
> "myfunc" symbol will be reimported from the "mymod" module at that
> point in time, and will therefore pick up any changes to "mymod" that
> have been made -- including changes made by a reload.  I did not mean
> to imply that "mymod" itself would be reloaded.

This is an important point, and I still don't think you have it exactly 
right.  When you say "including changes made by a reload", that really 
should say "ONLY IF the module has been reloaded".  Unless you reload 
it, the "mymod" that is in the module cache will never change, and 
therefore SomeFunc will always get the same version of myfunc().

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080109/0183a79c/attachment.html>


More information about the Ironpython-users mailing list