[Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'
alan.gauld at yahoo.co.uk
Tue Oct 9 12:10:24 EDT 2018
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?)
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor