[Slightly OT] Python COM & VB

Mark Hammond MarkH at ActiveState.com
Sun Aug 20 19:04:02 EDT 2000


"Scott" <kain at dynup.net> wrote in message
news:FzLy4I.AAJ at boss.cs.ohiou.edu...

> I am writing some Python COM servers to wrap some of my Python code
and
> creating a GUI for it in VB.  I'm noticing a problem that while
developing
> my VB code if I make a change in the Python COM code I have to
restart VB
> before it will use the new code.  I'm sure this is not a Python
problem, but
> perhaps someone who has ventured into this area could enlighten me
as to how
> I can make VB not do that?

You need to pretend that VB is just some other Python code using your
COM object, but as a regular Python object.  The exact same rules
apply.

If you are actually changing the class that is being used, then the
simplest way is to get the other code (VB) to release their reference
to the object, then to reload() the Python module, then create a new
instance.  If you are changing other code that your class simply uses
(ie, the class itself does not change, just some other module), then a
simple reload of the new module will work.

Try playing with this from pure-python code, and seeing how this all
works.  Then apply the same thing to the VB code.  For the COM object,
you can add the reload() to either one of the COM object methods, add
a new method just for the purpose, or even use a completely different
COM object (eg, the PythonTools sample object in win32com\servers)

> On a side not, I'd like to give my thanks to Mark and Andy (and
anyone else
> involved in the making) for PPW32.  This is an outstanding book and
has
> helped me out tremendously!

Thanks!

Mark.






More information about the Python-list mailing list