struct.unpack
g.franzkowiak
g.franzkowiak at onlinehome.de
Mon Oct 3 11:48:47 EDT 2005
Peter Otten schrieb:
> 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
>
Hello Peter,
was a node in my mind, the data comes as a string (with readfile always)
<< type(dataObject) = 'str' >> and
<< type(dataObject:4) = 'str' >> also ;-)
I've dropped the loop with list/join and the result is the same.
Thank you :-))
gerd
More information about the Python-list
mailing list