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
15a4950d
Kaydet (Commit)
15a4950d
authored
Şub 19, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add keyword arg support to itertools.compress().
üst
bc670849
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
test_itertools.py
Lib/test/test_itertools.py
+1
-0
itertoolsmodule.c
Modules/itertoolsmodule.c
+4
-6
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
15a4950d
...
...
@@ -310,6 +310,7 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
comb
,
sorted
(
set
(
cwr
)
&
set
(
perm
)))
# comb: both a cwr and a perm
def
test_compress
(
self
):
self
.
assertEqual
(
list
(
compress
(
data
=
'ABCDEF'
,
selectors
=
[
1
,
0
,
1
,
0
,
1
,
1
])),
list
(
'ACEF'
))
self
.
assertEqual
(
list
(
compress
(
'ABCDEF'
,
[
1
,
0
,
1
,
0
,
1
,
1
])),
list
(
'ACEF'
))
self
.
assertEqual
(
list
(
compress
(
'ABCDEF'
,
[
0
,
0
,
0
,
0
,
0
,
0
])),
list
(
''
))
self
.
assertEqual
(
list
(
compress
(
'ABCDEF'
,
[
1
,
1
,
1
,
1
,
1
,
1
])),
list
(
'ABCDEF'
))
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
15a4950d
...
...
@@ -2607,11 +2607,9 @@ compress_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject
*
seq1
,
*
seq2
;
PyObject
*
data
=
NULL
,
*
selectors
=
NULL
;
compressobject
*
lz
;
if
(
type
==
&
compress_type
&&
!
_PyArg_NoKeywords
(
"compress()"
,
kwds
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"compress"
,
2
,
2
,
&
seq1
,
&
seq2
))
static
char
*
kwargs
[]
=
{
"data"
,
"selectors"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"OO:compress"
,
kwargs
,
&
seq1
,
&
seq2
))
return
NULL
;
data
=
PyObject_GetIter
(
seq1
);
...
...
@@ -2689,7 +2687,7 @@ compress_next(compressobject *lz)
}
PyDoc_STRVAR
(
compress_doc
,
"compress(data
sequence, selector sequence
) --> iterator over selected data
\n
\
"compress(data
, selectors
) --> iterator over selected data
\n
\
\n
\
Return data elements corresponding to true selector elements.
\n
\
Forms a shorter iterator from selected data elements using the
\n
\
...
...
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