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
69df3761
Commit
69df3761
authored
Feb 04, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor doc fixes.
parent
d4d32de4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
8 deletions
+11
-8
Doc/glossary.rst
Doc/glossary.rst
+1
-1
Doc/library/collections.rst
Doc/library/collections.rst
+1
-1
Doc/library/itertools.rst
Doc/library/itertools.rst
+3
-3
Lib/test/test_itertools.py
Lib/test/test_itertools.py
+6
-3
No files found.
Doc/glossary.rst
View file @
69df3761
...
@@ -393,7 +393,7 @@ Glossary
...
@@ -393,7 +393,7 @@ Glossary
also :term:`immutable`.
also :term:`immutable`.
named tuple
named tuple
Any tuple
sub
class whose indexable elements are also accessible using
Any tuple
-like
class whose indexable elements are also accessible using
named attributes (for example, :func:`time.localtime` returns a
named attributes (for example, :func:`time.localtime` returns a
tuple-like object where the *year* is accessible either with an
tuple-like object where the *year* is accessible either with an
index such as ``t[0]`` or with a named attribute like ``t.tm_year``).
index such as ``t[0]`` or with a named attribute like ``t.tm_year``).
...
...
Doc/library/collections.rst
View file @
69df3761
...
@@ -206,7 +206,7 @@ For example::
...
@@ -206,7 +206,7 @@ For example::
.. method:: most_common([n])
.. method:: most_common([n])
Return a list of the *n* most common elements and their counts from the
Return a list of the *n* most common elements and their counts from the
most common to the least. If *n* not specified, :func:`most_common`
most common to the least. If *n*
is
not specified, :func:`most_common`
returns *all* elements in the counter. Elements with equal counts are
returns *all* elements in the counter. Elements with equal counts are
ordered arbitrarily::
ordered arbitrarily::
...
...
Doc/library/itertools.rst
View file @
69df3761
...
@@ -290,7 +290,7 @@ loops that truncate the stream.
...
@@ -290,7 +290,7 @@ loops that truncate the stream.
class groupby(object):
class groupby(object):
# [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
# [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
# [
(list(g)
) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
# [
list(g
) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
def __init__(self, iterable, key=None):
def __init__(self, iterable, key=None):
if key is None:
if key is None:
key = lambda x: x
key = lambda x: x
...
@@ -591,8 +591,8 @@ which incur interpreter overhead.
...
@@ -591,8 +591,8 @@ which incur interpreter overhead.
return map(function, count(start))
return map(function, count(start))
def nth(iterable, n):
def nth(iterable, n):
"Returns the nth item or
empty list
"
"Returns the nth item or
None
"
return
list(islice(iterable, n, n+1)
)
return
next(islice(iterable, n, None), None
)
def quantify(iterable, pred=bool):
def quantify(iterable, pred=bool):
"Count how many times the predicate is true"
"Count how many times the predicate is true"
...
...
Lib/test/test_itertools.py
View file @
69df3761
...
@@ -1371,8 +1371,8 @@ Samuele
...
@@ -1371,8 +1371,8 @@ Samuele
... return map(function, count(start))
... return map(function, count(start))
>>> def nth(iterable, n):
>>> def nth(iterable, n):
... "Returns the nth item or
empty list
"
... "Returns the nth item or
None
"
... return
list(islice(iterable, n, n+1)
)
... return
next(islice(iterable, n, None), None
)
>>> def quantify(iterable, pred=bool):
>>> def quantify(iterable, pred=bool):
... "Count how many times the predicate is true"
... "Count how many times the predicate is true"
...
@@ -1469,7 +1469,10 @@ perform as purported.
...
@@ -1469,7 +1469,10 @@ perform as purported.
[0, 2, 4, 6]
[0, 2, 4, 6]
>>> nth('abcde', 3)
>>> nth('abcde', 3)
['d']
'd'
>>> nth('abcde', 9) is None
True
>>> quantify(range(99), lambda x: x%2==0)
>>> quantify(range(99), lambda x: x%2==0)
50
50
...
...
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