Re: [Tutor] array('c')

2014-05-01 Thread Ian D
Thanks > To: tutor@python.org > From: breamore...@yahoo.co.uk > Date: Thu, 1 May 2014 16:40:54 +0100 > Subject: Re: [Tutor] array('c') > > On 01/05/2014 15:38, Ian D wrote: > > Hi > > > > I have this part of code and am unsure as to the effect of the array('c') > > part. > > > > Is it creating a

Re: [Tutor] Final review

2014-05-01 Thread Mark Lawrence
On 01/05/2014 06:21, Scott W Dunning wrote: Hello, I am new to python and have a final review coming up and was hoping you could help me answer a few questions I came across while studying. So, I get a little confused about lists sometimes. This one is a little hard to make heads or tails of.

Re: [Tutor] array('c')

2014-05-01 Thread Stefan Behnel
Ian D, 01.05.2014 16:38: > I have this part of code and am unsure as to the effect of the array('c') > part. The argument that you pass into the constructor is a type identifier. https://docs.python.org/2/library/array.html#array.array The different types are defined at the top of that page. I

Re: [Tutor] array('c')

2014-05-01 Thread Mark Lawrence
On 01/05/2014 15:38, Ian D wrote: Hi I have this part of code and am unsure as to the effect of the array('c') part. Is it creating an array and adding 'c' as its first value? This does not seem to be the case. Thanks n = len(cmd) a = array('c') a.append(chr((n>> 24) & 0xFF))

Re: [Tutor] array('c')

2014-05-01 Thread Peter Otten
Ian D wrote: > I have this part of code and am unsure as to the effect of the array('c') > part. Is it creating an array and adding 'c' as its first value? No, the first arg to array.array() is the typecode; data may be passed as the second argument. The typecode "c" creates an array of 8-bit ch

[Tutor] array('c')

2014-05-01 Thread Ian D
Hi I have this part of code and am unsure as to the effect of the array('c') part. Is it creating an array and adding 'c' as its first value? This does not seem to be the case. Thanks n = len(cmd) a = array('c') a.append(chr((n>> 24) & 0xFF)) a.append(chr((n>> 16) & 0

Re: [Tutor] Final review

2014-05-01 Thread Steven D'Aprano
On Wed, Apr 30, 2014 at 10:21:41PM -0700, Scott W Dunning wrote: > So, I get a little confused about lists sometimes. This one is a > little hard to make heads or tails of. I get confused about how to > tell how many lists are within one list like the one below. How many > lists are located

Re: [Tutor] 2s complement binary for negative

2014-05-01 Thread Dave Angel
Ian D Wrote in message: > Can anyone clarify please? > > > Just reading this: > > https://wiki.python.org/moin/BitwiseOperators > > > The section on 2's complement binary for negative integers. > > > It states: > > > "Thus the number -5 is treated by bitwise operators as if it were writte

Re: [Tutor] 2s complement binary for negative

2014-05-01 Thread Peter Otten
Ian D wrote: > Can anyone clarify please? > > > Just reading this: > https://wiki.python.org/moin/BitwiseOperators > The section on 2's complement binary for negative integers. > It states: > "Thus the number -5 is treated by bitwise operators as if it were written > "...11101

Re: [Tutor] bit shifting

2014-05-01 Thread Peter Otten
Ian D wrote: > I am trying to follow some code. It is basically a python scratch > interfacing script. > Anyway part of the script has this code. > Searching google for >> greater than signs in code with python has its > issues. > Can anyone clarify this stuff. > I know its about 4 bytes of data.

Re: [Tutor] Final review

2014-05-01 Thread Chris “Kwpolska” Warrick
On Thu, May 1, 2014 at 7:21 AM, Scott W Dunning wrote: > Hello, I am new to python and have a final review coming up and was hoping > you could help me answer a few questions I came across while studying. > > > So, I get a little confused about lists sometimes. This one is a little hard > to ma

Re: [Tutor] bit shifting

2014-05-01 Thread Ian D
But what is the purpose of ANDing with 255? Would this not just return the same value? eg 1010 and with would just return 1010 or 1010 > From: dux...@hotmail.com > To: tutor@python.org > Date: Thu, 1 May 2014 09:53:15 + > Subject: Re

Re: [Tutor] bit shifting

2014-05-01 Thread Ian D
Ok I am getting somewhere with this now. A bitshift followed by ANDing the result of the shift! So I think n>> 24 & 0xFF is shift n 3 bytes right, save results in n and then AND n with 255 decimal? > From: dux...@hotmail.com > To: tutor@python.org

[Tutor] 2s complement binary for negative

2014-05-01 Thread Ian D
Can anyone clarify please? Just reading this: https://wiki.python.org/moin/BitwiseOperators The section on 2's complement binary for negative integers. It states: "Thus the number -5 is treated by bitwise operators as if it were written "...111011". " I am wondering why

[Tutor] Final review

2014-05-01 Thread Scott W Dunning
Hello, I am new to python and have a final review coming up and was hoping you could help me answer a few questions I came across while studying. So, I get a little confused about lists sometimes. This one is a little hard to make heads or tails of. I get confused about how to tell how many l

[Tutor] bit shifting

2014-05-01 Thread Ian D
I am trying to follow some code. It is basically a python scratch interfacing script. Anyway part of the script has this code. Searching google for >> greater than signs in code with python has its issues. Can anyone clarify this stuff. I know its about 4 bytes of data. It looks like