[python-win32] Executing eval function in VBscript

bob gailer bgailer at alum.rpi.edu
Mon Feb 4 16:05:11 CET 2008


Janakiraman Mohanakrishnan wrote:
>
> Hi all,
>         I have been trying to execute python library functions VBscript,
>        
>         Public sc As New MSScriptControl.ScriptControl
>        
>         sc.Language = "python"
>         Value = sc.Eval("{'key':[1,2]}")
>        
>         While i try to execute the above shown code i am getting 
> exception by saying "type mismatch" that is due to eval function which 
> returns dictionary in this         case where in VB does not support 
> this, how shall i proceed in this case.
That's hard to answer until we know what you want to accomplish! Tell us 
more. What problem are you trying to solve?

Also I'm not very familiar with MSScriptControl. I googled it and found 
no useful documentation. Do you have any references to it?

FWIW I did the following from a Python session:

 >>> import win32com.client
 >>> c = win32com.client.Dispatch('MSScriptControl.ScriptControl')
 >>> c.Language='python'
 Debugging interfaces not available - debugging is disabled..
 >>> c.Eval("3 if 1 else 4")
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "<COMObject MSScriptControl.ScriptControl>", line 2, in Eval
com_error: (-2147352567, 'Exception occurred.', (0, 'Python COM Server 
Internal Error', "Unexpected Python Error: <type 
'exceptions.TypeError'>: Objects of type 'dict' can not be converted to 
a COM VARIANT", None, 0, -2147467259), None)

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



More information about the python-win32 mailing list