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
8ea99993
Commit
8ea99993
authored
Jan 01, 2009
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix highlighting
parent
99a1b20b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Doc/library/itertools.rst
Doc/library/itertools.rst
+4
-4
No files found.
Doc/library/itertools.rst
View file @
8ea99993
...
@@ -547,7 +547,7 @@ can be combined.
...
@@ -547,7 +547,7 @@ can be combined.
.. doctest::
.. doctest::
# Show a dictionary sorted and grouped by value
>>>
# Show a dictionary sorted and grouped by value
>>> from operator import itemgetter
>>> from operator import itemgetter
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
>>> di = sorted(d.iteritems(), key=itemgetter(1))
>>> di = sorted(d.iteritems(), key=itemgetter(1))
...
@@ -558,9 +558,9 @@ can be combined.
...
@@ -558,9 +558,9 @@ can be combined.
2 ['b', 'd', 'f']
2 ['b', 'd', 'f']
3 ['g']
3 ['g']
# Find runs of consecutive numbers using groupby. The key to the solution
>>>
# Find runs of consecutive numbers using groupby. The key to the solution
# is differencing with a range so that consecutive numbers all appear in
>>>
# is differencing with a range so that consecutive numbers all appear in
# same group.
>>>
# same group.
>>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
>>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
>>> for k, g in groupby(enumerate(data), lambda (i,x):i-x):
>>> for k, g in groupby(enumerate(data), lambda (i,x):i-x):
... print map(itemgetter(1), g)
... print map(itemgetter(1), g)
...
...
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