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


Groups > comp.lang.python > #43858

Strange behavior for a 2D list

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ruyttenhove@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '16,': 0.03; '22,': 0.09; 'received:209.85.219': 0.09; 'python': 0.11; '2.7.3': 0.16; '23,': 0.16; '24,': 0.16; '32,': 0.16; '33,': 0.16; 'thanks,': 0.17; '>>>': 0.22; '&gt;&gt;&gt;': 0.24; '31,': 0.24; '15,': 0.26; 'code:': 0.26; 'tried': 0.27; 'list:': 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; '25,': 0.31; 'received:209.85': 0.35; 'received:google.com': 0.35; 'received:209': 0.37; 'expected': 0.38; 'to:addr:python-list': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; '30,': 0.65; '26,': 0.68
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=ZOWLat+NY6L0vtl4DUN+OvIboi/7XB2uk5FWaxWpcPU=; b=ZJL8Hd7GePJYbSsWT5v78adxH1gQ1rJnLzIXm5PHdMzF0EMRfTY1s5fyRTCb4te22A DliNdak4XWyL2ovoJeWnUTPip4Vh2MzMa/7hvLZJY9EXjUGUwz0eXCijvWVX3QrHisic qa08EsDrkBEPW85e67QyYE7XTGGL+k19bL4Bgv/M/yoa6G1Srn/21edOreEKGVsPCJzU KTuJjxoTU+SvYaQgIBGCWMkqyDHO4UdtUbpqQemFRdSdAC4Vmw2egUHU414gBS7XLHEG 38LHNDA03DsZgUiA3qjCL7K7soQj4KyFRmabU+OjZ0UcrJW3LlWa2IrBm4Zxofg3rq4m GT+A==
MIME-Version 1.0
X-Received by 10.182.226.162 with SMTP id rt2mr1512975obc.9.1366317318914; Thu, 18 Apr 2013 13:35:18 -0700 (PDT)
Date Thu, 18 Apr 2013 14:35:18 -0600
Subject Strange behavior for a 2D list
From "Robrecht W. Uyttenhove" <ruyttenhove@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=001a11c2e93c7214b404daa88a39
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.793.1366317327.3114.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366317327 news.xs4all.nl 2283 [2001:888:2000:d::a6]:40115
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43858

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello,

I tried out the following code:
y=[range(0,7),range(7,14),range(14,21),range(21,28),range(28,35)]
>>> y
[[0, 1, 2, 3, 4, 5, 6],
 [7, 8, 9, 10, 11, 12, 13],
 [14, 15, 16, 17, 18, 19, 20],
 [21, 22, 23, 24, 25, 26, 27],
 [28, 29, 30, 31, 32, 33, 34]]

>>> y[1:5:2][::3]
[[7, 8, 9, 10, 11, 12, 13]]

I expected the 2D list:
[[ 7, 10, 13],
 [21, 24, 27]]

Any ideas?

Thanks,

Rob

PS: I used Python 2.7.3

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


Thread

Strange behavior for a 2D list "Robrecht W. Uyttenhove" <ruyttenhove@gmail.com> - 2013-04-18 14:35 -0600
  Re: Strange behavior for a 2D list John Gordon <gordon@panix.com> - 2013-04-18 21:13 +0000

csiph-web