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
341deb74
Kaydet (Commit)
341deb74
authored
May 02, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
The previous made the stop argument optional.
It is better to be explicit and just allow stop to be None.
üst
14ef54cd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
13 deletions
+10
-13
libitertools.tex
Doc/lib/libitertools.tex
+7
-10
test_itertools.py
Lib/test/test_itertools.py
+1
-1
itertoolsmodule.c
Modules/itertoolsmodule.c
+2
-2
No files found.
Doc/lib/libitertools.tex
Dosyayı görüntüle @
341deb74
...
...
@@ -197,9 +197,9 @@ by functions or loops that truncate the stream.
If
\var
{
start
}
is non-zero, then elements from the iterable are skipped
until start is reached. Afterward, elements are returned consecutively
unless
\var
{
step
}
is set higher than one which results in items being
skipped. If
\var
{
stop
}
is
not specified or is
\code
{
None
}
, then iteration
continues indefinitely; otherwise, it stops at the specified position.
Unlike regular slicing,
skipped. If
\var
{
stop
}
is
\code
{
None
}
, then iteration continues until
the iterator is exhausted, if at all; otherwise, it stops at the specified
position.
Unlike regular slicing,
\function
{
islice()
}
does not support negative values for
\var
{
start
}
,
\var
{
stop
}
, or
\var
{
step
}
. Can be used to extract related fields
from data where the internal structure has been flattened (for
...
...
@@ -208,13 +208,10 @@ by functions or loops that truncate the stream.
\begin{verbatim}
def islice(iterable, *args):
if args:
s = slice(*args)
next = s.start or 0
stop = s.stop
step = s.step or 1
else:
next, stop, step = 0, None, 1
s = slice(*args)
next = s.start or 0
stop = s.stop
step = s.step or 1
for cnt, element in enumerate(iterable):
if cnt < next:
continue
...
...
Lib/test/test_itertools.py
Dosyayı görüntüle @
341deb74
...
...
@@ -78,12 +78,12 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
list
(
islice
(
xrange
(
100
),
*
args
)),
range
(
*
tgtargs
))
# Test stop=None
self
.
assertEqual
(
list
(
islice
(
xrange
(
10
))),
range
(
10
))
self
.
assertEqual
(
list
(
islice
(
xrange
(
10
),
None
)),
range
(
10
))
self
.
assertEqual
(
list
(
islice
(
xrange
(
10
),
2
,
None
)),
range
(
2
,
10
))
self
.
assertEqual
(
list
(
islice
(
xrange
(
10
),
1
,
None
,
2
)),
range
(
1
,
10
,
2
))
# Test invalid arguments
self
.
assertRaises
(
TypeError
,
islice
,
xrange
(
10
))
self
.
assertRaises
(
TypeError
,
islice
,
xrange
(
10
),
1
,
2
,
3
,
4
)
self
.
assertRaises
(
ValueError
,
islice
,
xrange
(
10
),
-
5
,
10
,
1
)
self
.
assertRaises
(
ValueError
,
islice
,
xrange
(
10
),
1
,
-
5
,
-
1
)
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
341deb74
...
...
@@ -477,7 +477,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
isliceobject
*
lz
;
numargs
=
PyTuple_Size
(
args
);
if
(
!
PyArg_ParseTuple
(
args
,
"O
|O
Ol:islice"
,
&
seq
,
&
a1
,
&
a2
,
&
step
))
if
(
!
PyArg_ParseTuple
(
args
,
"O
O|
Ol:islice"
,
&
seq
,
&
a1
,
&
a2
,
&
step
))
return
NULL
;
if
(
numargs
==
2
)
{
...
...
@@ -491,7 +491,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return
NULL
;
}
}
}
else
if
(
numargs
==
3
||
numargs
==
4
)
{
}
else
{
start
=
PyInt_AsLong
(
a1
);
if
(
start
==
-
1
&&
PyErr_Occurred
())
{
PyErr_Clear
();
...
...
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