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
92d1951f
Commit
92d1951f
authored
Apr 10, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add examples.
parent
4bdc4c94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
Doc/library/itertools.rst
Doc/library/itertools.rst
+23
-23
No files found.
Doc/library/itertools.rst
View file @
92d1951f
...
@@ -36,32 +36,32 @@ operator can be mapped across two vectors to form an efficient dot-product:
...
@@ -36,32 +36,32 @@ operator can be mapped across two vectors to form an efficient dot-product:
**Infinite Iterators:**
**Infinite Iterators:**
================== ================= ========
=========================================
================== ================= =================================================
=========================================
Iterator Arguments Results
Iterator Arguments Results Example
================== ================= ========
=========================================
================== ================= =================================================
=========================================
:func:`count` start start, start+1, start+2, ...
:func:`count` start, [step] start, start+step, start+2*step, ... ``count(10) --> 10 11 12 13 14 ...``
:func:`cycle` p p0, p1, ... plast, p0, p1, ...
:func:`cycle` p p0, p1, ... plast, p0, p1, ... ``cycle('ABCD') --> A B C D A B C D ...``
:func:`repeat` elem [,n] elem, elem, elem, ... endlessly or up to n times
:func:`repeat` elem [,n] elem, elem, elem, ... endlessly or up to n times ``repeat(10, 3) --> 10 10 10``
================== ================= ========
=========================================
================== ================= =================================================
=========================================
**Iterators terminating on the shortest input sequence:**
**Iterators terminating on the shortest input sequence:**
==================== ============================
=================================================
==================== ============================ ================================================= ============
=================================================
Iterator Arguments Results
Iterator Arguments Results Example
==================== ============================
=================================================
==================== ============================ ================================================= ============
=================================================
:func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ...
:func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ... ``chain('ABC', 'DEF') --> A B C D E F``
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
:func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
:func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
:func:`ifilter` pred, seq elements of seq where pred(elem) is True
:func:`ifilter` pred, seq elements of seq where pred(elem) is True ``ifilter(lambda x: x%2, range(10)) --> 1 3 5 7 9``
:func:`ifilterfalse` pred, seq elements of seq where pred(elem) is False
:func:`ifilterfalse` pred, seq elements of seq where pred(elem) is False ``ifilterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step]
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
:func:`imap` func, p, q, ... func(p0, q0), func(p1, q1), ...
:func:`imap` func, p, q, ... func(p0, q0), func(p1, q1), ... ``imap(pow, (2,3,10), (5,2,3)) --> 32 9 1000``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ...
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
:func:`tee` it, n it1, it2 , ... itn splits one iterator into n
:func:`tee` it, n it1, it2 , ... itn splits one iterator into n
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
:func:`izip` p, q, ... (p[0], q[0]), (p[1], q[1]), ...
:func:`izip` p, q, ... (p[0], q[0]), (p[1], q[1]), ... ``izip('ABCD', 'xy') --> Ax By``
:func:`izip_longest` p, q, ... (p[0], q[0]), (p[1], q[1]), ...
:func:`izip_longest` p, q, ... (p[0], q[0]), (p[1], q[1]), ... ``izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D-``
==================== ============================
=================================================
==================== ============================ ================================================= ============
=================================================
**Combinatoric generators:**
**Combinatoric generators:**
...
...
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