Comparing PythonWin and IDLE?

Michael Scharf Michael.Scharf at gmx.de
Fri Apr 14 21:43:33 CEST 2000


Charlie Derr wrote:
> 
>         instead of:
> 
> import myModule
> 
>         try this:
> 
> reload(myModule)
> 
>         and you should be able to get your recently modified changes to take effect
> without restarting python

Well, not quite:

if you wrire (in another module)

  from myModule import MyFunction,MyClass
  ...
  MyFunction()
  my_callback=MyFunction
  my_instance=MyClass()

reload will *not* change the function nor the myinstance.
If you would write:

  import myModule
  ...
  myModule.MyFunction()
  my_callback=myModule.MyFunction
  my_instance=myModule.MyClass()

the new version of MyFunction an MyClass will be called, but
existing instances of MyClass will not be changed to the new version.
Also the old version of my_callback would be called.

I know it is possible to change the code of existing functions.
So, with some ticks it should be possible to replace the code
of existing functions. The same must be done for all mutable objects
(list, dicts etc.). Only not mutable direct imported variable (int,
string, tuple etc.) cannot be changed that way.

I just wonder if anybody has written such a clever reimport...

Michael
-- 
     ''''\     Michael Scharf
    ` c-@@     TakeFive Software GmbH, a Wind River Company
    `    >     http://www.WindRiver.com
     \_ V      mailto:Michael.Scharf at gmx.de



More information about the Python-list mailing list