Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6af7fe0

Browse files
committed
Add example
1 parent a2e21cb commit 6af7fe0

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Doc/whatsnew/whatsnew25.tex

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,21 @@ \section{PEP 309: Partial Function Application}
6060
server_log = functional.partial(log, subsystem='server')
6161
\end{verbatim}
6262

63-
Here's another example, from a program that uses PyGTk.
63+
Here's another example, from a program that uses PyGTk. Here a
64+
context-sensitive pop-up menu is being constructed dynamically. The
65+
callback provided for the menu option is a partially applied version
66+
of the \method{open_item()} method, where the first argument has been
67+
provided.
6468

65-
% XXX add example from my GTk programming
69+
\begin{verbatim}
70+
...
71+
class Application:
72+
def open_item(self, path):
73+
...
74+
def init (self):
75+
open_func = functional.partial(self.open_item, item_path)
76+
popup_menu.append( ("Open", open_func, 1) )
77+
\end{verbatim}
6678

6779

6880
\begin{seealso}

0 commit comments

Comments
 (0)