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
bbf0d504
Commit
bbf0d504
authored
Dec 06, 2003
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add groupby()
parent
dcb56b3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
Doc/whatsnew/whatsnew24.tex
Doc/whatsnew/whatsnew24.tex
+28
-0
No files found.
Doc/whatsnew/whatsnew24.tex
View file @
bbf0d504
...
@@ -266,6 +266,34 @@ details.
...
@@ -266,6 +266,34 @@ details.
\item
The
\module
{
imaplib
}
module now supports IMAP's THREAD command.
\item
The
\module
{
imaplib
}
module now supports IMAP's THREAD command.
(Contributed by Yves Dionne.)
(Contributed by Yves Dionne.)
\item
The
\module
{
itertools
}
module gained a
\function
{
groupby(
\var
{
iterable
}
\optional
{
,
\var
{
func
}}
)
}
function,
inspired by the GROUP BY clause from SQL.
\var
{
iterable
}
returns a succession of elements, and the optional
\var
{
func
}
is a function that takes an element and returns a key
value; if omitted, the key is simply the element itself.
\function
{
groupby()
}
then groups the elements into subsequences
which have matching values of the key, and returns a series of 2-tuples
containing the key value and an iterator over the subsequence.
Here's an example. The
\var
{
key
}
function simply returns whether a
number is even or odd, so the result of
\function
{
groupby()
}
is to
return consecutive runs of odd or even numbers.
\begin{verbatim}
>>> import itertools
>>> L = [2,4,6, 7,8,9,11, 12, 14]
>>> for key
_
val, it in itertools.groupby(L, lambda x: x
% 2):
... print key
_
val, list(it)
...
0 [2, 4, 6]
1 [7]
0 [8]
1 [9, 11]
0 [12, 14]
>>>
\end{verbatim}
\item
A new
\function
{
getsid()
}
function was added to the
\item
A new
\function
{
getsid()
}
function was added to the
\module
{
posix
}
module that underlies the
\module
{
os
}
module.
\module
{
posix
}
module that underlies the
\module
{
os
}
module.
(Contributed by J. Raynor.)
(Contributed by J. Raynor.)
...
...
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