|
1
|
This was written to emulate a flexible version of delegates from the C# language. Default arguments can be set and changed, and default arguments can be totally be replaced by new arguments on-the-fly. The delegate class was primarily written for working with Tkinter.
When try to design a GUI with Tkinter, functions sometimes need to be dynamically bound to events with some of the parameters already filled in. Python 2.5 appears to possibly being doing something to solve this problem in with some helpful, new solutions; but until then, delegates may be what some people are currently looking for. The Delegate class basically forms a wrapper around a function and automatically changes how it operates based on whether or not arguments were passed to the wrapper when called. Default arguments and keyword arguments can easily be changed once the Delegate object is created.
Tags: extending
|
1 comment
Add a comment
Sign in to comment
Download
Copy to clipboard

What's wrong with closures, or partial function application? (The function 'partial' doesn't exist in 2.4, but it's not hard to write.)