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
e6ed33a6
Kaydet (Commit)
e6ed33a6
authored
Şub 12, 2004
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix minor markup error: \code{for} --> \keyword{for}
üst
b1e5b505
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
tut.tex
Doc/tut/tut.tex
+7
-6
No files found.
Doc/tut/tut.tex
Dosyayı görüntüle @
e6ed33a6
...
...
@@ -4286,7 +4286,7 @@ finally the instance converted to a string using the built-in function
\section
{
Iterators
\label
{
iterators
}}
By now, you've probably noticed that most container objects can be looped
over using a
\
code
{
for
}
statement:
over using a
\
keyword
{
for
}
statement:
\begin
{
verbatim
}
for element in
[
1
,
2
,
3
]
:
...
...
@@ -4302,11 +4302,12 @@ for line in open("myfile.txt"):
\end
{
verbatim
}
This style of access is clear, concise, and convenient. The use of iterators
pervades and unifies Python. Behind the scenes, the
\code
{
for
}
statement calls
\function
{
iter
()
}
on the container object. The function returns an iterator
object that defines the method
\method
{
next
()
}
which accesses elements in the
container one at a time. When there are no more elements,
\method
{
next
()
}
raises a
\exception
{
StopIteration
}
exception which tells the
\code
{
for
}
loop
pervades and unifies Python. Behind the scenes, the
\keyword
{
for
}
statement calls
\function
{
iter
()
}
on the container object. The
function returns an iterator object that defines the method
\method
{
next
()
}
which accesses elements in the container one at a
time. When there are no more elements,
\method
{
next
()
}
raises a
\exception
{
StopIteration
}
exception which tells the
\keyword
{
for
}
loop
to terminate. This example shows how it all works:
\begin
{
verbatim
}
...
...
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