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
06919a17
Kaydet (Commit)
06919a17
authored
Mar 18, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
a much better example
üst
6ffe852f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
18 deletions
+7
-18
functions.rst
Doc/library/functions.rst
+7
-18
No files found.
Doc/library/functions.rst
Dosyayı görüntüle @
06919a17
...
...
@@ -596,24 +596,13 @@ available. They are listed here in alphabetical order.
its :meth:`next` method; if the value returned is equal to *sentinel*,
:exc:`StopIteration` will be raised, otherwise the value will be returned.
Example usage: ::
>>> iterator = iter(range(10))
>>> iterator
<listiterator object at 0x86b50>
>>> iterator.next()
0
>>> iterator.next()
1
>>> def my_generator():
... for i in range(10):
... yield i
...
>>> iterator = iter(my_generator().next, 7)
>>> iterator
<callable-iterator object at 0x86bb0>
>>> list(iterator)
[0, 1, 2, 3, 4, 5, 6]
One useful application of the second form of :func:`iter` is to read lines of
a file until a certain line is reached. The following example reads a file
until ``"STOP"`` is reached: ::
with open("mydata.txt") as fp:
for line in iter(fp.readline, "STOP"):
process_line(line)
.. versionadded:: 2.2
...
...
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