Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.110 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.78; '*S*': 0.00; 'python': 0.11; '"=="': 0.16; '"is"': 0.16; 'compute': 0.16; 'rule.': 0.16; 'simplest': 0.16; 'index': 0.16; 'bit': 0.19; 'thanks.': 0.20; 'header:User- Agent:1': 0.23; 'compare': 0.26; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'cells': 0.31; 'probably': 0.32; 'guess': 0.33; 'subject:lists': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'next': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'changing': 0.37; 'two': 0.37; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'previous': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; 'content-disposition:inline': 0.62; 'happen': 0.63; 'more': 0.64; 'biggest': 0.67; 'safe': 0.72; '8bit': 0.91; 'generation.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=16yfrZPeCVSYLSa8Cdh2TWP4rHKL0iumUOF3eG4q+z4=; b=KeXlU0lefgOdDP1h3KOtVI+EIBJHL1Wro575Q7EkkbnYBKQfTSlMb2OPpepLviPCxz bHCeZI2YTTsv1uL7J9sdAUTENe+cM2PvK3SsAMVhCnasCfJvyB62bT6HzNkJCulApzaE qdCyv6+BbaZ7BHm4dhIZIG2XKIyO1xQPMD7iDFL+jbMkwSB347cqDYYurBObbsG3bfJG O6UgPkmL46Uo7+PQqTZTXmRTpxStRomtgSaVi4opvD6+YRxNOp+yCqfdpDi0O5WDUa69 4m0UM7BSlWgLMj417UhjSx64R+y28WeHyawoNiXOF0iG0Y7lK0+/CnxGfF44/hBpvgut ig9Q== X-Received: by 10.180.91.106 with SMTP id cd10mr18353471wib.6.1366293047106; Thu, 18 Apr 2013 06:50:47 -0700 (PDT) Date: Thu, 18 Apr 2013 15:50:44 +0200 From: aaB To: python-list@python.org Subject: Re: a couple of things I don't understand wrt lists Mail-Followup-To: python-list@python.org References: <20130416153701.GA18377@gmail.com> <20130417102537.GA19967@gmail.com> <20130418130101.GA22185@gmail.com> <516FF3CA.7030407@davea.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <516FF3CA.7030407@davea.name> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366293048 news.xs4all.nl 2207 [2001:888:2000:d::a6]:41447 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43828 > The second guess, more likely, is that you're using "is" to compare > numbers, and that's never a safe idea. It might happen to work for > small numbers, but you should be using ==. The second guess was right, changing "is" for "==" solved it, thanks. I still have a lot to learn about python semantics. The 8 bit pattern is used to store the rule, not the cells. To compute the next cell, I index the rule list, based on the values of that cell and it's two immediate neighbours in the previous generation. This probably isn't the simplest way. Since I am using only 3 cells to compute 1 cell, the biggest index would be 2**3 - 1, hence the 8bit pattern for the rule.