Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
53de1902
Kaydet (Commit)
53de1902
authored
Eyl 04, 2007
tarafından
Thomas Wouters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update ref docs on slicing.
üst
aeaa546d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
30 deletions
+13
-30
expressions.rst
Doc/reference/expressions.rst
+13
-30
No files found.
Doc/reference/expressions.rst
Dosyayı görüntüle @
53de1902
...
...
@@ -513,14 +513,10 @@ or list). Slicings may be used as expressions or as targets in assignment or
:keyword:`del` statements. The syntax for a slicing:
.. productionlist::
slicing: `simple_slicing` | `extended_slicing`
simple_slicing: `primary` "[" `short_slice` "]"
extended_slicing: `primary` "[" `slice_list` "]"
slicing: `primary` "[" `slice_list` "]"
slice_list: `slice_item` ("," `slice_item`)* [","]
slice_item: `expression` | `proper_slice`
proper_slice: `short_slice` | `long_slice`
short_slice: [`lower_bound`] ":" [`upper_bound`]
long_slice: `short_slice` ":" [`stride`]
proper_slice: [`lower_bound`] ":" [`upper_bound`] [ ":" [`stride`] ]
lower_bound: `expression`
upper_bound: `expression`
stride: `expression`
...
...
@@ -530,36 +526,23 @@ expression list also looks like a slice list, so any subscription can be
interpreted as a slicing. Rather than further complicating the syntax, this is
disambiguated by defining that in this case the interpretation as a subscription
takes priority over the interpretation as a slicing (this is the case if the
slice list contains no proper slice). Similarly, when the slice list has
exactly one short slice and no trailing comma, the interpretation as a simple
slicing takes priority over that as an extended slicing.
.. XXX is the next paragraph stil correct?
The semantics for a simple slicing are as follows. The primary must evaluate to
a sequence object. The lower and upper bound expressions, if present, must
evaluate to plain integers; defaults are zero and the ``sys.maxint``,
respectively. If either bound is negative, the sequence's length is added to
it. The slicing now selects all items with index *k* such that ``i <= k < j``
where *i* and *j* are the specified lower and upper bounds. This may be an
empty sequence. It is not an error if *i* or *j* lie outside the range of valid
indexes (such items don't exist so they aren't selected).
slice list contains no proper slice).
.. index::
single: start (slice object attribute)
single: stop (slice object attribute)
single: step (slice object attribute)
The semantics for a
n extended slicing are as follows. The primary must evaluate
to a
mapping object, and it is indexed with a key that is constructed from the
slice list, as follows. If the slice list contains at least one comma, the
key
is a tuple containing the conversion of the slice items; otherwise, the
conversion of the lone slice item is the key. The conversion of a slice
item
that is an expression is that expression. The conversion of a proper slice is a
slice
object (see section :ref:`types`) whose :attr:`start`, :attr:`stop` and
:attr:`st
ep` attributes are the values of the expressions given as lower bound,
upper bound and stride, respectively, substituting ``None`` for miss
ing
expressions.
The semantics for a
slicing are as follows. The primary must evaluate to a
mapping object, and it is indexed with a key that is constructed from the
slice list, as follows. If the slice list contains at least one comma, the
key
is a tuple containing the conversion of the slice items; otherwise, the
conversion of the lone slice item is the key. The conversion of a slice
item that is an expression is that expression. The conversion of a proper
slice
is a slice object (see section :ref:`types`) whose :attr:`start`,
:attr:`st
op` and :attr:`step` attributes are the values of the expressions
given as lower bound, upper bound and stride, respectively, substitut
ing
``None`` for missing
expressions.
.. _calls:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment