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
828d932a
Kaydet (Commit)
828d932a
authored
Kas 23, 2014
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
PEP 479: Don't let StopIteration bubble out of calls to next() inside a generator.
üst
1bf47293
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
itertools.rst
Doc/library/itertools.rst
+16
-4
ElementPath.py
Lib/xml/etree/ElementPath.py
+12
-3
No files found.
Doc/library/itertools.rst
Dosyayı görüntüle @
828d932a
...
...
@@ -104,7 +104,10 @@ loops that truncate the stream.
# accumulate([1,2,3,4,5]) --> 1 3 6 10 15
# accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120
it = iter(iterable)
total = next(it)
try:
total = next(it)
except StopIteration:
return
yield total
for element in it:
total = func(total, element)
...
...
@@ -405,7 +408,10 @@ loops that truncate the stream.
def _grouper(self, tgtkey):
while self.currkey == tgtkey:
yield self.currvalue
self.currvalue = next(self.it) # Exit on StopIteration
try:
self.currvalue = next(self.it)
except StopIteration:
return
self.currkey = self.keyfunc(self.currvalue)
...
...
@@ -429,7 +435,10 @@ loops that truncate the stream.
# islice('ABCDEFG', 0, None, 2) --> A C E G
s = slice(*args)
it = iter(range(s.start or 0, s.stop or sys.maxsize, s.step or 1))
nexti = next(it)
try:
nexti = next(it)
except StopIteration:
return
for i, element in enumerate(iterable):
if i == nexti:
yield element
...
...
@@ -587,7 +596,10 @@ loops that truncate the stream.
def gen(mydeque):
while True:
if not mydeque: # when the local deque is empty
newval = next(it) # fetch a new value and
try:
newval = next(it) # fetch a new value and
except StopIteration:
return
for d in deques: # load it to all the deques
d.append(newval)
yield mydeque.popleft()
...
...
Lib/xml/etree/ElementPath.py
Dosyayı görüntüle @
828d932a
...
...
@@ -114,7 +114,10 @@ def prepare_self(next, token):
return
select
def
prepare_descendant
(
next
,
token
):
token
=
next
()
try
:
token
=
next
()
except
StopIteration
:
return
if
token
[
0
]
==
"*"
:
tag
=
"*"
elif
not
token
[
0
]:
...
...
@@ -148,7 +151,10 @@ def prepare_predicate(next, token):
signature
=
[]
predicate
=
[]
while
1
:
token
=
next
()
try
:
token
=
next
()
except
StopIteration
:
return
if
token
[
0
]
==
"]"
:
break
if
token
[
0
]
and
token
[
0
][:
1
]
in
"'
\"
"
:
...
...
@@ -261,7 +267,10 @@ def iterfind(elem, path, namespaces=None):
if
path
[:
1
]
==
"/"
:
raise
SyntaxError
(
"cannot use absolute path on element"
)
next
=
iter
(
xpath_tokenizer
(
path
,
namespaces
))
.
__next__
token
=
next
()
try
:
token
=
next
()
except
StopIteration
:
return
selector
=
[]
while
1
:
try
:
...
...
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