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
e0906d13
Commit
e0906d13
authored
Aug 31, 2007
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few more fixes to the tutorial
parent
7aa02e65
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
Doc/tutorial/controlflow.rst
Doc/tutorial/controlflow.rst
+1
-2
Doc/tutorial/datastructures.rst
Doc/tutorial/datastructures.rst
+5
-5
No files found.
Doc/tutorial/controlflow.rst
View file @
e0906d13
...
@@ -436,8 +436,7 @@ function like this::
...
@@ -436,8 +436,7 @@ function like this::
print("-- I'm sorry, we're all out of", kind)
print("-- I'm sorry, we're all out of", kind)
for arg in arguments: print arg
for arg in arguments: print arg
print('-'*40)
print('-'*40)
keys = keywords.keys()
keys = sorted(keywords.keys())
keys.sort()
for kw in keys: print(kw, ':', keywords[kw])
for kw in keys: print(kw, ':', keywords[kw])
It could be called like this::
It could be called like this::
...
...
Doc/tutorial/datastructures.rst
View file @
e0906d13
...
@@ -400,12 +400,12 @@ Here is a small example using a dictionary::
...
@@ -400,12 +400,12 @@ Here is a small example using a dictionary::
>>> tel['irv'] = 4127
>>> tel['irv'] = 4127
>>> tel
>>> tel
{'guido': 4127, 'irv': 4127, 'jack': 4098}
{'guido': 4127, 'irv': 4127, 'jack': 4098}
>>>
tel.keys(
)
>>>
list(tel.keys()
)
['guido', 'irv', 'jack']
['guido', 'irv', 'jack']
>>> tel.has_key('guido')
True
>>> 'guido' in tel
>>> 'guido' in tel
True
True
>>> 'jack' not in tel
False
The :func:`dict` constructor builds dictionaries directly from lists of
The :func:`dict` constructor builds dictionaries directly from lists of
key-value pairs stored as tuples. When the pairs form a pattern, list
key-value pairs stored as tuples. When the pairs form a pattern, list
...
@@ -435,10 +435,10 @@ Looping Techniques
...
@@ -435,10 +435,10 @@ Looping Techniques
==================
==================
When looping through dictionaries, the key and corresponding value can be
When looping through dictionaries, the key and corresponding value can be
retrieved at the same time using the :meth:`ite
rite
ms` method. ::
retrieved at the same time using the :meth:`items` method. ::
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
>>> for k, v in knights.ite
rite
ms():
>>> for k, v in knights.items():
... print(k, v)
... print(k, v)
...
...
gallahad the pure
gallahad the pure
...
...
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