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
a60ba5b0
Commit
a60ba5b0
authored
May 31, 2006
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'functional' module was renamed to 'functools'
parent
69924352
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
Doc/whatsnew/whatsnew25.tex
Doc/whatsnew/whatsnew25.tex
+6
-6
No files found.
Doc/whatsnew/whatsnew25.tex
View file @
a60ba5b0
...
...
@@ -125,7 +125,7 @@ Wouters.}
%======================================================================
\section
{
PEP 309: Partial Function Application
\label
{
pep-309
}}
The
\module
{
funct
ional
}
module is intended to contain tools for
The
\module
{
funct
ools
}
module is intended to contain tools for
functional-style programming. Currently it only contains a
\class
{
partial()
}
function, but new functions will probably be added
in future versions of Python.
...
...
@@ -136,7 +136,7 @@ parameters filled in. Consider a Python function \code{f(a, b, c)};
you could create a new function
\code
{
g(b, c)
}
that was equivalent to
\code
{
f(1, b, c)
}
. This is called ``partial function application'',
and is provided by the
\class
{
partial
}
class in the new
\module
{
funct
ional
}
module.
\module
{
funct
ools
}
module.
The constructor for
\class
{
partial
}
takes the arguments
\code
{
(
\var
{
function
}
,
\var
{
arg1
}
,
\var
{
arg2
}
, ...
...
...
@@ -147,18 +147,18 @@ with the filled-in arguments.
Here's a small but realistic example:
\begin{verbatim}
import funct
ional
import funct
ools
def log (message, subsystem):
"Write the contents of 'message' to the specified subsystem."
print '
%s: %s' % (subsystem, message)
...
server
_
log = funct
ional
.partial(log, subsystem='server')
server
_
log = funct
ools
.partial(log, subsystem='server')
server
_
log('Unable to open socket')
\end{verbatim}
Here's another example, from a program that uses PyGT
k
. Here a
Here's another example, from a program that uses PyGT
K
. Here a
context-sensitive pop-up menu is being constructed dynamically. The
callback provided for the menu option is a partially applied version
of the
\method
{
open
_
item()
}
method, where the first argument has been
...
...
@@ -170,7 +170,7 @@ class Application:
def open
_
item(self, path):
...
def init (self):
open
_
func = funct
ional
.partial(self.open
_
item, item
_
path)
open
_
func = funct
ools
.partial(self.open
_
item, item
_
path)
popup
_
menu.append( ("Open", open
_
func, 1) )
\end{verbatim}
...
...
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