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


Groups > comp.lang.python > #43674

Re: Newbie questions on Python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <matt.walker.jones@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'subject:Python': 0.06; '*is*': 0.09; '[1,': 0.09; 'received:209.85.219': 0.09; 'python': 0.11; '-1,': 0.16; 'reversing': 0.16; 'slice.': 0.16; 'slicing:': 0.16; 'subject:questions': 0.16; 'index': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'wed,': 0.18; 'all,': 0.19; 'example': 0.22; 'programming': 0.22; 'coding': 0.22; 'email addr:gmail.com&gt;': 0.22; 'to:name :python-list@python.org': 0.22; '&gt;': 0.26; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; '(usually': 0.31; '>>>>': 0.31; 'url:python': 0.33; 'received:209.85': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'list': 0.37; 'received:209': 0.37; 'step': 0.37; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'url:mail': 0.40; 'url:3': 0.61; 'first': 0.61; 'taking': 0.65; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=2rGmpqXnrofLYDRXWtEuDYI7cWrxK/ininVd7zHeJ/I=; b=icAyityYckWmFQQG21Z2EnA4ulPs5YlcJce3z4uR7msj9S0D+20IBoQb1u4qiNx4HI tfBEfj1lQJ3SKICMg3TnfvweOyCrKRkMgl7eRZlW2h+NIUQTCQvWlZA3AhL2qHmOumWo vZ0bE/e6wcJEw7+5g1cm/ZCrkK8i/nzivLFfF4Vv5JksiF6e5yIHFyp3NxqSSrrHs1/u 3qmwBdvQjg3s6ABvx4lfSKy683/ihij0phoIB74rGnp1fhu0V8RJUzperFJKqUxz3wsq ubJGp6N6K1vJpMNA35IU+t3TuhctID4LkmdW10e4PEd6F7dxvlQ1I+r/iR33fL8vjoEc ARDg==
X-Received by 10.182.156.103 with SMTP id wd7mr978911obb.33.1366126451668; Tue, 16 Apr 2013 08:34:11 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAPTjJmoEpVxUXFM0gX+JCb3xMP6-TpQLzJ6Ln9ryK1b=dFoK_g@mail.gmail.com>
References <a6562e3b-29af-4953-bc8b-49fa634d1be7@googlegroups.com> <CAPTjJmoEpVxUXFM0gX+JCb3xMP6-TpQLzJ6Ln9ryK1b=dFoK_g@mail.gmail.com>
From Matt Jones <matt.walker.jones@gmail.com>
Date Tue, 16 Apr 2013 10:33:51 -0500
Subject Re: Newbie questions on Python
To "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=f46d0444e835df0eb704da7c19b5
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.667.1366126460.3114.python-list@python.org> (permalink)
Lines 96
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366126460 news.xs4all.nl 2580 [2001:888:2000:d::a6]:49740
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43674

Show key headers only | View raw


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

When slicing: l[start:end:step]

In your example of "a[2::-1]" you are reversing the list by using a step of
-1, then you are slicing at index 2 (third element).

*Matt Jones*


On Tue, Apr 16, 2013 at 10:30 AM, Chris Angelico <rosuav@gmail.com> wrote:

> On Wed, Apr 17, 2013 at 1:20 AM,  <idkfaidkfaidkfa@gmail.com> wrote:
> > Hi all,
> > i'm programming in python for the first time (usually i use C as
> programming language). I don't understand these results:
> >
> >>>> a=[1,2,3,4,5]
> >>>> a[:-1]
> > [1, 2, 3, 4]
> >>>> a[::-1]
> > [5, 4, 3, 2, 1]
> >>>> a[2::-1]
> > [3, 2, 1]
> >
> > what does a[2::-1] means?
>
> That's taking a slice. This page has something to say on the subject:
>
> http://docs.python.org/3.3/tutorial/introduction.html
>
> By the way, regarding your email address: there are no cheat codes in
> Python... either that, or Python *is* a cheat code. :)
>
> ChrisA
> [[ VERY HAPPY CODING ADDED ]]
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Newbie questions on Python idkfaidkfaidkfa@gmail.com - 2013-04-16 08:20 -0700
  Re: Newbie questions on Python Chris Angelico <rosuav@gmail.com> - 2013-04-17 01:30 +1000
    Re: Newbie questions on Python Walter Hurry <walterhurry@lavabit.com> - 2013-04-16 21:40 +0000
      Re: Newbie questions on Python Chris Angelico <rosuav@gmail.com> - 2013-04-17 07:53 +1000
  Re: Newbie questions on Python Matt Jones <matt.walker.jones@gmail.com> - 2013-04-16 10:33 -0500
  Re: Newbie questions on Python Neil Cerutti <neilc@norwich.edu> - 2013-04-16 15:41 +0000
    Re: Newbie questions on Python Lele Gaifax <lele@metapensiero.it> - 2013-04-16 18:06 +0200
      Re: Newbie questions on Python Neil Cerutti <neilc@norwich.edu> - 2013-04-16 17:16 +0000

csiph-web