Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
da623ed9
Commit
da623ed9
authored
May 01, 2011
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split combined code/doctest code blocks in two blocks, to enable proper highlighting.
parent
e97f14c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
Doc/tutorial/classes.rst
Doc/tutorial/classes.rst
+5
-2
No files found.
Doc/tutorial/classes.rst
View file @
da623ed9
...
...
@@ -730,7 +730,6 @@ built-in function; this example shows how it all works::
>>> next(it)
'c'
>>> next(it)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
next(it)
...
...
@@ -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``::
class Reverse:
"
Iterator for looping over a sequence backwards
"
"
""Iterator for looping over a sequence backwards.""
"
def __init__(self, data):
self.data = data
self.index = len(data)
...
...
@@ -754,6 +753,8 @@ returns an object with a :meth:`__next__` method. If the class defines
self.index = self.index - 1
return self.data[self.index]
::
>>> rev = Reverse('spam')
>>> iter(rev)
<__main__.Reverse object at 0x00A1DB50>
...
...
@@ -782,6 +783,8 @@ easy to create::
for index in range(len(data)-1, -1, -1):
yield data[index]
::
>>> for char in reverse('golf'):
... 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