DDE (eSignal)

Thomas Heller theller at ctypes.org
Thu Nov 30 20:21:33 CET 2006


BBands schrieb:
> I have a Python ap that needs current stock prices, which I want to get
> from eSignal's DDE server. Following the win32all example:
> 
> import win32ui
> import dde
> server = dde.CreateServer()
> server.Create("eSignalDDE")
> conversation = dde.CreateConversation(server)
> conversation.ConnectTo("WINROS", "Last")
> last = conversation.Request("$spx")
> print last
> 
> Which almost works. The return in PythonWin is the correct price as a
> string with some extra chartacters appended.
> 
> '1402.670000000000\x00\x12\x00*\x00\x00\x004\xfb\x12\x00\xfd\x1a\xd9w4\xc1\x00'
> 
> Any thoughts on this?
> 
> TIA,
> 
>     jab
> 

Looks like a bug, either in the dde module or the dde server.
But it's easy to find a workaround:

>>> '1402.670000000000\x00\x12\x00*\x00\x00\x004\xfb\x12\x00\xfd\x1a\xd9w4\xc1\x00'.split("\0")[0]
'1402.670000000000'
>>>

Thomas




More information about the Python-list mailing list