[python-win32] How to return dict from Python COM

Rodrigo Strauss rodrigo at 1bit.com.br
Mon Jul 24 22:03:26 CEST 2006


To use a Scripting.Dictionary, here goes an example code:


>>> from win32com.client import Dispatch
>>> d = Dispatch('Scripting.Dictionary')
>>> d.Add('key1', 'Value1')
>>> d.Add('key2', 2)
>>> d.Add(3, 'Value3')

Just return the object 'd' from your python COM object.

Rodrigo Strauss

On 7/23/06, hari haran <comhari at hotmail.com> wrote:
> Hi,
> How can I create a COM compatible dictionary.
> So The python code has to be modified to return a Com compatible dict. Is
> that right
> Should I  use Scripting.Dictionary in Python code.
>
> Ay pointers on Creating a COM compatible dictionary will be of help.
> Thanks
> -Hari
>
>
>
> The Python dict object is not a compatible COM object, you need to use
> a COM compatible dictionary. You can develop one or use the
> Scripting.Dictionary:
>
> http://windowssdk.msdn.microsoft.com/en-us/library/x4k5wbx4.aspx
>
> Rodrigo Strauss
>
> On 7/22/06, hari haran <comhari at hotmail.com> wrote:
> >Hi,
> >
> >I am trying to write a Simple COM using Python. I am trying to use it in
> >VB.
> >1.
> >If I return a dict from Python VB throws a COM exception saying that dict
> >cannot be converted tio COM VARIANT.
> >2.
> >This is just a testing. What I am trying to see is to develope UI in VB and
> >try to use Python as my engine. Is there any proven ways to do it. (Other
> >than using Python UIs like Tkinter, WxPython etc)
> >
> >
> >Thanks
> >--Hari
> >
> >_________________________________________________________________
> >Fall in Love... Get married! Join FREE!
> >http://www.shaadi.com/ptnr.php?ptnr=msnhottag
> >
> >_______________________________________________
> >Python-win32 mailing list
> >Python-win32 at python.org
> >http://mail.python.org/mailman/listinfo/python-win32
>
> _________________________________________________________________
> Best IT jobs on naukri.com
> http://www.naukri.com/tieups/tieups.php?othersrcp=3246
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


More information about the Python-win32 mailing list