[Tutor] reading an input stream

Cameron Simpson cs at zip.com.au
Thu Jan 7 17:25:40 EST 2016


On 07Jan2016 17:22, richard kappler <richkappler at gmail.com> wrote:
>On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson <cs at zip.com.au> wrote:
>
>>
>> Just a few followup remarks:
>>
>> This is all Python 3, where bytes and strings are cleanly separated.
>> You've got a binary stream with binary delimiters, so we're reading binary
>> data and returning the binary XML in between. We separately decode this
>> into a string for handing to your XML parser. Just avoid Python 2
>> altogether; this can all be done in Python 2 but it is not as clean, and
>> more confusing.
>>
>
>Love to, can't. Splunk uses 2.7 so that's what we have to work with. That
>will not change in the forseeable future. Doing other homework right now,
>but will more closely review this and the other posts that have come in
>since I left work later tonight or first thing in the morning.

Ok. You should still be ok, but things like bs[0] == 0x02 will need to be bs[0] 
== '\x02' and so forth, because you get str objects back from reads.

The rest of the suggested code should still broadly work.

Cheers,
Cameron Simpson <cs at zip.com.au>


More information about the Tutor mailing list