Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43752

Re: a couple of things I don't understand wrt lists

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mecagonoisician@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.04; 'output': 0.05; 'session.': 0.07; '[1,': 0.09; 'latter': 0.09; 'will,': 0.09; 'python': 0.11; 'def': 0.12; '"python"': 0.16; 'iterating': 0.16; 'reproduce': 0.16; 'rewritten': 0.16; 'bit': 0.19; 'trying': 0.19; "python's": 0.19; 'written': 0.21; 'print': 0.22; 'header:User-Agent:1': 0.23; "haven't": 0.24; 'script': 0.25; 'push': 0.26; 'post': 0.26; 'asking': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'list:': 0.30; 'getting': 0.31; 'posting': 0.31; 'cells': 0.31; 'guess': 0.33; 'received:74.125.82': 0.34; 'something': 0.35; 'subject:lists': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'ca,': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; "i'll": 0.36; 'list': 0.37; 'being': 0.38; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'received:74.125': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'back': 0.62; 'content-disposition:inline': 0.62; 'complete': 0.62; "you've": 0.63; 'real': 0.63; 'more': 0.64; 'other.': 0.75; 'console,': 0.84; 'forward,': 0.84
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=ZduXtgzadjk8xbTnqYl8/j11ouMs74xoukN8RCshnaY=; b=c+C7bXqFHKREn88xlGXxUuz4AYgx+vYfHe4kjzmSe59COq6qTeTilrxxmBgT/3T+qf JkKUTExs0OTYfJOSiLvjCq0c+6TcSgi/bHGw6EpH2Yz1PPY1raembygz6+mAuoE4AGfZ LScdEavFNbdKyOCiDhB+YMidWPYi0JtRwO+3jJ+bQzvSZkhBOP42m4ONH6IftT4PqXbS +9wXzEHT1T6ibu13/dYf9a3KJ0kvRz8jjtogz0HpdCPuwe5gMIOau/5LB7opSuILF790 4hRe52Zb7YOvE+Vhb2KHraHVrnGIxPM2kbhCj6k0GVHz356F1lvN2G4z3JY6zyxQ2hQx DepA==
X-Received by 10.194.178.39 with SMTP id cv7mr10069027wjc.53.1366194339944; Wed, 17 Apr 2013 03:25:39 -0700 (PDT)
Date Wed, 17 Apr 2013 12:25:37 +0200
From aaB <mecagonoisician@gmail.com>
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> <CAPTjJmqRB0eiG9peDOU+Ow_1rqq2u=xXcUduyxUm3gAhrzMjHg@mail.gmail.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <CAPTjJmqRB0eiG9peDOU+Ow_1rqq2u=xXcUduyxUm3gAhrzMjHg@mail.gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.719.1366194346.3114.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366194346 news.xs4all.nl 2575 [2001:888:2000:d::a6]:41419
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43752

Show key headers only | View raw


Hello,

Thanks for all your replies, things are getting clearer.


- copy/paste vs retyping:
Several people have remarked that I had retyped instead of copy/pasting.
This is exactly what happened, the fact is I haven't figured out yet how to
enable copy/pasting from urxvt to vim.
I'll try to get this done before posting output from an interactive session.


- iterating a list:
If I understand what you've told me,

bitpattern = [1, 0, 0, 1, 1, 0, 1]
for bit in bitpattern: 
  print bit

and 

bitpattern = [1, 0, 0, 1, 1, 0, 1]
for i in range(len(bitpattern)): 
  print bitpattern[i]

are equivalent, the former being more "python" and the latter being something
like C written using python syntax.


- the "complement" thing:
I haven't yet tried to reproduce this, but I will, and I will post back if I see
this happening again, this time with a real log of python's interactive console,
or a complete script which people can use.


- list comprehension:
I wasn't at all aware of this, thanks a lot for pointing it out.
I had an other function that generated a list of cells for the CA, each cell
being randomly alive or dead.
I have rewritten it using list comprehension,

def populate(n):
  random.seed()
  return [random.randint(0,1) for i in range(n)]

which works the same as my previous, C-like, version but feels much better.

I might come back to you all but you've already given me a good push forward, so
I guess I'll be trying to use it as much as I can before asking for an other.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: a couple of things I don't understand wrt lists aaB <mecagonoisician@gmail.com> - 2013-04-17 12:25 +0200
  Re: a couple of things I don't understand wrt lists darnold <darnold992000@yahoo.com> - 2013-04-17 06:43 -0700

csiph-web