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


Groups > comp.lang.python > #98861

What meaning is 'a[0:10:2]'?

X-Received by 10.66.62.198 with SMTP id a6mr29151688pas.47.1447633623702; Sun, 15 Nov 2015 16:27:03 -0800 (PST)
X-Received by 10.50.25.131 with SMTP id c3mr240635igg.6.1447633623632; Sun, 15 Nov 2015 16:27:03 -0800 (PST)
Path csiph.com!xmission!news.glorb.com!i2no3746279igv.0!news-out.google.com!f6ni3712igq.0!nntp.google.com!i2no3330701igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Sun, 15 Nov 2015 16:27:03 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=50.100.117.144; posting-account=SZ_svQkAAACWRFG2bDA-zgq8ILyl4-vo
NNTP-Posting-Host 50.100.117.144
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <237d9a48-6db3-48aa-89b4-66730cdced7d@googlegroups.com> (permalink)
Subject What meaning is 'a[0:10:2]'?
From fl <rxjwg98@gmail.com>
Injection-Date Mon, 16 Nov 2015 00:27:03 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:98861

Show key headers only | View raw


hi,

When I learn slice, I have a new question on the help file. If I set:

pp=a[0:10:2]

pp is array([1, 3])

I don't know how a[0:10:2] gives array([1, 3]).

I know matlab a lot, but here it seems quite different. Could you tell me
what meaning a[0:10:2] is?


Thanks,



class slice(object)
 |  slice(stop)
 |  slice(start, stop[, step])
 |  
 |  Create a slice object.  This is used for extended slicing (e.g. a[0:10:2]).

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


Thread

What meaning is 'a[0:10:2]'? fl <rxjwg98@gmail.com> - 2015-11-15 16:27 -0800
  Re: What meaning is 'a[0:10:2]'? Ben Finney <ben+python@benfinney.id.au> - 2015-11-16 11:46 +1100
    Names [was Re: What meaning is 'a[0:10:2]'?] Steven D'Aprano <steve@pearwood.info> - 2015-11-16 23:57 +1100
      Re: Names [was Re: What meaning is 'a[0:10:2]'?] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-16 20:06 -0500
  Re: What meaning is 'a[0:10:2]'? Tim Chase <python.list@tim.thechases.com> - 2015-11-15 18:48 -0600
  Re: What meaning is 'a[0:10:2]'? Steven D'Aprano <steve@pearwood.info> - 2015-11-16 23:29 +1100

csiph-web