struct.unpack
Peter Otten
__peter__ at web.de
Mon Oct 3 07:17:48 EDT 2005
g.franzkowiak wrote:
> The dataObject was read from a named pipe as an byte stream
>
> state, dataObject = win32file.ReadFile(handle, nbytes, None)
> print repr(dataObject)
> ==> '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0.....
>
> With Frederiks help operates this fine
I do not doubt that. My point was that instead of the suggested
# Fredrik
obj = "".join(list(dataObject[:4]))
the simpler
# me
obj = dataObject[:4]
might work as well. I cannot test it here, but judging from
http://aspn.activestate.com/ASPN/docs/ActivePython/2.3/pywin32/win32file__ReadFile_meth.html
the resulting dataObject is a buffer and buffer slices seem to be just
strings.
> print repr(dataObject)
> ==> '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0.....
Hmm, that looks as if dataObject were a string -- please post the result of
print type(dataObject)
just to help me restore my peace of mind :-)
Peter
More information about the Python-list
mailing list