Re: [Tutor] working with bit arrays

2009-12-02 Thread Dave Angel
Robert Berman wrote: Emille, I do think he meant bit 20 to 32 rather than 20 to 40. Unless, of course, he's dealing with a 64 bit word. You posted out of order (top--osted). So I am forced to put my response elsewhere. I am delighted with all the help I have received on this topic and I a

Re: [Tutor] Do you use unit testing?

2009-12-02 Thread Kent Johnson
Uncle Bob Martin has written a great post about TDD: http://blog.objectmentor.com/articles/2009/10/06/echoes-from-the-stone-age "Look, TDD is not my religion, it is one of my disciplines. It’s like dual entry bookkeeping for accountants, or sterile procedure for surgeons. Professionals adopt such

Re: [Tutor] working with bit arrays

2009-12-02 Thread Robert Berman
Emille, I do think he meant bit 20 to 32 rather than 20 to 40. Unless, of course, he's dealing with a 64 bit word. I am delighted with all the help I have received on this topic and I am gleefully learning anding and oring, but not too much on the EOR side. Thanks again for all the assistance.

Re: [Tutor] working with bit arrays

2009-12-02 Thread Emile van Sebille
On 12/2/2009 4:10 PM GilJohnson said... Using an array of 32 bit integers, you have to go to some trouble to slice out, say, bits 20 to 40. I think I agree -- if in fact it's not impossible. Tell me that's a typo or take a moment to explain what I'm misunderstanding... Emile

Re: [Tutor] Moving from Python 2 to Python 3

2009-12-02 Thread Alan Gauld
"wesley chun" wrote i believe the 1st ed is 3.0 and the 2nd ed is 3.1 but haven't confirmed with him yet. I bought the 1st edition which is definitely 3.0. It was quite good I thought. I doubt I'll buy another edition just for the 3.1 uplift, but if he covers the new themed widgets in tki

Re: [Tutor] working with bit arrays

2009-12-02 Thread Alan Gauld
"Robert Berman" wrote I am trying to represent a number as a list of bits: for example the bit representation of the integer 8. Numbers are already represented as arrays of bits, thats how they are stored. I am almost certain there is a relatively easy way to convert an integer that can b

Re: [Tutor] working with bit arrays

2009-12-02 Thread GilJohnson
As`Kent Johnson pointed out, you don't need to convert anything to strings, etc. An integer _is_ a bit array, and individual bits can be tested using the bitwise operators. For your example, if A is an integer you can test bit 8 with: if A & (1 << 8): dosomething There is a simple example on the Py

Re: [Tutor] working with bit arrays

2009-12-02 Thread Alan Plum
On Mi, 2009-12-02 at 13:08 -0500, Robert Berman wrote: > Hi, > > I am trying to represent a number as a list of bits: for example the > bit representation of the integer 8. I did find a number of articles > pertaining to a module called bitarray but I was unable to > download/install that package.

Re: [Tutor] Moving from Python 2 to Python 3

2009-12-02 Thread wesley chun
>> I have the first edition of your book. What is the difference between >> two editions? i believe the 1st ed is 3.0 and the 2nd ed is 3.1 but haven't confirmed with him yet. -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2

Re: [Tutor] Moving from Python 2 to Python 3

2009-12-02 Thread Kent Johnson
I don't know that you will reach Mark through this list, I forwarded his post from another list. There is some info on the book web site: http://www.qtrac.eu/py3book.html When replying to a digest, please - change the subject line to something relevant - don't quote the entire digest in your reply

Re: [Tutor] working with bit arrays

2009-12-02 Thread Kent Johnson
On Wed, Dec 2, 2009 at 1:08 PM, Robert Berman wrote: > Hi, > > I am trying to represent a number as a list of bits: for example the bit > representation of the integer 8. I did find a number of articles pertaining > to a module called bitarray but I was unable to download/install that > package. I

Re: [Tutor] Tutor Digest, Vol 70, Issue 5

2009-12-02 Thread aivars
ounce. A helpful summary of the differences >>> between Python 2 and 3 (though some of the differences were introduced >>> well before Python 3). >> >>> It is available as a free PDF download (no registration or anything) >>>

Re: [Tutor] working with bit arrays

2009-12-02 Thread Chris Fuller
My approach has been to store it as an array and then build the integer as needed. This code requires Python 2.5 or later. def bits2int(l): return sum([2**i if j else 0 for i,j in enumerate(l)]) To convert the other way: def int2bits(m, n): return [int(bool(m&(1<>= inc return i flo

Re: [Tutor] working with bit arrays

2009-12-02 Thread Robert Berman
Wayne, Thank you very much. Robert On Wed, 2009-12-02 at 12:48 -0600, Wayne Werner wrote: > On Wed, Dec 2, 2009 at 12:08 PM, Robert Berman > wrote: > > Hi, > > I am trying to represent a number as a list of bits: for > example the bit representation of the inte

Re: [Tutor] working with bit arrays

2009-12-02 Thread Wayne Werner
On Wed, Dec 2, 2009 at 12:08 PM, Robert Berman wrote: > Hi, > > I am trying to represent a number as a list of bits: for example the bit > representation of the integer 8. I did find a number of articles pertaining > to a module called bitarray but I was unable to download/install that > package

[Tutor] working with bit arrays

2009-12-02 Thread Robert Berman
Hi, I am trying to represent a number as a list of bits: for example the bit representation of the integer 8. I did find a number of articles pertaining to a module called bitarray but I was unable to download/install that package. I am using Linux on Ubuntu 9.10; Python 2.6.2. I am almost certa

Re: [Tutor] Moving from Python 2 to Python 3: A 4 page "cheatsheet"

2009-12-02 Thread Eddie
Thanks 2009/12/3 Wayne Werner > > > On Wed, Dec 2, 2009 at 8:13 AM, Joerg Woelke wrote: > >> Alan Gauld [091202 15:07]: >> > > >> http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf >> > >> > >> > It didn't work for me I always got forwarded to the B

Re: [Tutor] Moving from Python 2 to Python 3: A 4 page "cheatsheet"

2009-12-02 Thread Wayne Werner
On Wed, Dec 2, 2009 at 8:13 AM, Joerg Woelke wrote: > Alan Gauld [091202 15:07]: > > > > http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf > > > > > > It didn't work for me I always got forwarded to the Book "home page" > > on InformIT > Worked for m

Re: [Tutor] Moving from Python 2 to Python 3: A 4 page "cheatsheet"

2009-12-02 Thread Joerg Woelke
* Alan Gauld [091202 15:07]: > >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf > > > It didn't work for me I always got forwarded to the Book "home page" > on InformIT Worked for me with wget(1). -- You are capable of planning your future. __

Re: [Tutor] Moving from Python 2 to Python 3: A 4 page "cheatsheet"

2009-12-02 Thread Kent Johnson
On Wed, Dec 2, 2009 at 8:56 AM, Alan Gauld wrote: > > "Kent Johnson" wrote > >> Forwarded from python-announce. A helpful summary of the differences >> between Python 2 and 3 (though some of the differences were introduced >> well before Python 3). > >> It is available as a free PDF download (no

[Tutor] pygame help with livewires

2009-12-02 Thread Skylar Struble
ok so its working and drops a normal cow and randomly a green cow but i want it to be able to tell when you collide with the green cow cause its gonna be a powerup. heres the code for my program. # Pizza Panic # Player must catch falling pizzas before they hit the ground from livewires import ga

Re: [Tutor] Moving from Python 2 to Python 3: A 4 page "cheatsheet"

2009-12-02 Thread Alan Gauld
"Kent Johnson" wrote Forwarded from python-announce. A helpful summary of the differences between Python 2 and 3 (though some of the differences were introduced well before Python 3). It is available as a free PDF download (no registration or anything) from InformIT's website. Here's the di

[Tutor] Fwd: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Kent Johnson
Forwarded from python-announce. A helpful summary of the differences between Python 2 and 3 (though some of the differences were introduced well before Python 3). Kent -- Forwarded message -- From: Mark Summerfield To: comp-lang-python-annou...@moderators.isc.org Date: Tue, 1 Dec

[Tutor] Polyfit works like this

2009-12-02 Thread Eike Welk
On Tuesday 01 December 2009, questions anon wrote: > I would now like to add a line of best fit. I think the command is > polyfit()?? > But I can't seem to get it to work These are the steps to make polyval work. I typed it into an 'ipython -pylab' session; I hope I included all relevant lines an