Skip to content

Commit 7f32591

Browse files
author
rhettinger
committed
Make functional.partial() more closely match the spec by emulating some useful features of regular functions:
* Made weak referencable. * Allow attribute access so a user can set __name__, __doc__, etc. git-svn-id: http://svn.python.org/projects/python/trunk@38590 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 635baad commit 7f32591

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Doc/lib/libfunctional.tex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ \section{\module{functional} ---
4444
two:
4545
\begin{verbatim}
4646
>>> basetwo = partial(int, base=2)
47+
>>> basetwo.__doc__('Convert base 2 string to an int.')
4748
>>> basetwo('10010')
4849
18
4950
\end{verbatim}
@@ -71,3 +72,10 @@ \subsection{\class{partial} Objects \label{partial-objects}}
7172
The keyword arguments that will be supplied when the \class{partial} object
7273
is called.
7374
\end{memberdesc}
75+
76+
\class{partial} objects are like \class{function} objects in that they are
77+
callable, weak referencable, and can have attributes. There are some
78+
important differences. For instance, the \member{__name__} and
79+
\member{__doc__} attributes are not created automatically. Also,
80+
\class{partial} objects defined in classes behave like static methods and
81+
do not transform into bound methods during instance attribute look-up.

0 commit comments

Comments
 (0)