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
da623ed9
Kaydet (Commit)
da623ed9
authored
May 01, 2011
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Split combined code/doctest code blocks in two blocks, to enable proper highlighting.
üst
e97f14c1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
classes.rst
Doc/tutorial/classes.rst
+5
-2
No files found.
Doc/tutorial/classes.rst
Dosyayı görüntüle @
da623ed9
...
@@ -730,7 +730,6 @@ built-in function; this example shows how it all works::
...
@@ -730,7 +730,6 @@ built-in function; this example shows how it all works::
>>> next(it)
>>> next(it)
'c'
'c'
>>> next(it)
>>> next(it)
Traceback (most recent call last):
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 1, in ?
next(it)
next(it)
...
@@ -742,7 +741,7 @@ returns an object with a :meth:`__next__` method. If the class defines
...
@@ -742,7 +741,7 @@ returns an object with a :meth:`__next__` method. If the class defines
:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
class Reverse:
class Reverse:
"
Iterator for looping over a sequence backwards
"
"
""Iterator for looping over a sequence backwards.""
"
def __init__(self, data):
def __init__(self, data):
self.data = data
self.data = data
self.index = len(data)
self.index = len(data)
...
@@ -754,6 +753,8 @@ returns an object with a :meth:`__next__` method. If the class defines
...
@@ -754,6 +753,8 @@ returns an object with a :meth:`__next__` method. If the class defines
self.index = self.index - 1
self.index = self.index - 1
return self.data[self.index]
return self.data[self.index]
::
>>> rev = Reverse('spam')
>>> rev = Reverse('spam')
>>> iter(rev)
>>> iter(rev)
<__main__.Reverse object at 0x00A1DB50>
<__main__.Reverse object at 0x00A1DB50>
...
@@ -782,6 +783,8 @@ easy to create::
...
@@ -782,6 +783,8 @@ easy to create::
for index in range(len(data)-1, -1, -1):
for index in range(len(data)-1, -1, -1):
yield data[index]
yield data[index]
::
>>> for char in reverse('golf'):
>>> for char in reverse('golf'):
... print(char)
... print(char)
...
...
...
...
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