mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Add example
This commit is contained in:
parent
a2e21cb945
commit
6af7fe0563
1 changed files with 14 additions and 2 deletions
|
@ -60,9 +60,21 @@ def log (message, subsystem):
|
||||||
server_log = functional.partial(log, subsystem='server')
|
server_log = functional.partial(log, subsystem='server')
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Here's another example, from a program that uses PyGTk.
|
Here's another example, from a program that uses PyGTk. 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
|
||||||
|
provided.
|
||||||
|
|
||||||
% XXX add example from my GTk programming
|
\begin{verbatim}
|
||||||
|
...
|
||||||
|
class Application:
|
||||||
|
def open_item(self, path):
|
||||||
|
...
|
||||||
|
def init (self):
|
||||||
|
open_func = functional.partial(self.open_item, item_path)
|
||||||
|
popup_menu.append( ("Open", open_func, 1) )
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
|
||||||
\begin{seealso}
|
\begin{seealso}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue