[Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'
wachobc at gmail.com
Tue Oct 9 12:30:20 EDT 2018
Yes, 2.7 here. I wanted to use 3, but the API only supports 2.7.
And, I'm not about to get into rewriting an API. :)
So, octets it is. Thank you for the clarification.
Yes, my background is C, let me look into your suggested method.
It is the shifting across those byte boundaries that is really messing
me up. If only they were all just bytes.. but then that wouldn't be
any 'fun' would it?
On 10/9/18, Alan Gauld via Tutor <tutor at python.org> wrote:
> On 09/10/18 13:45, Chip Wachob wrote:
>> Another related question. How do I know I want to do dir(int) vs.. I
>> don't know dir(long)?
> Because you want to convert the byte array into an int.
> And there is no long in Python...
>> And, when I do dir(int) I get the following results. I must not be
>> seeing the from_bytes in this list...
>> ['__abs__', '__add__', '__and__', '__class__', '__cmp__',
> Ah, I assume this means you are using Python v2.7?
> I assumed you were using v3. The bytes operations were,
> I think, added in v3.
> That complicates things, I think you are probably best
> converting your byte list into a string and then using
> the struct module to convert your bytearray into an int.
> (struct is a bit like C's sscanf function if
> that helps - I seem to recall you know C?)
> Alan G
> Author of the Learn to Program web site
> Follow my photo-blog on Flickr at:
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
More information about the Tutor