New in this release: Functional.py - support for functional programming in Python - version 1.0
I'm happy to announce the availability of the March 2001 release of the Xoltar Toolkit.
The Xoltar Toolkit is free software, released under the GNU LGPL, and may be obtained from:
http://www.sourceforge.net/projects/xoltar-toolkit
Comments are always welcome, please direct to: xoltar@starship.python.net
Xoltar Toolkit (March 2001) contains:
functional.py version 1.0
threadpool.py version 1.0
lazy.py version 0.7
Functional.py provides support for a functional style of Python programming.
It includes support for closures, curried functions, many higher order
functions for composing, joining or otherwise manipulating functions
and other callables.
Lazy.py provides support for lazy expressions, lazy tuples
(functional programming languages call these lazy lists, but since lists are
mutable in Python, tuples are closer in meaning), and lazy equivalents
for map, filter, reduce, and zip.
Threadpool.py uses the threading and Queue modules to create a pool of reusable
threads. After creating an instance of ThreadPool, one queues functions to be
executed. The pool dispatches the functions to the waiting threads, which
call them. Also includes conveniences for locking.
Detailed changes for this version of functional.py:
02/26/2000 - Version 1.0
Added Bindings, a class with write-once attributes, useful for ensuring
variable bindings don't change unexpectedly. Also added namespace()
function, which extracts the attributes off a Bindings object into
a dictionary, suitable for eval()'ing with.
Changed name of with_error to error_handler to help make clear the fact
that it's generating a new function which handles its own errors, not
trying to call a function now and dealing with any errors it may raise.
Added trap_error for those sorts of situations. Both allow the second
argument to be non-callable. If that argument is not callable, then in
the case of an error, the error is silently discarded, and the supplied
argument (or None) is returned instead.
Added 'error' function which is a functional equivalent to the 'raise'
statement and can therefore be used within expressions, including lambdas.
Added mapdict, filterdict, invertdict, and dict functions for creating
and manipulating dictionaries in a way similar to using map and filter
on lists. I'll get around to reducedict if anyone else can figure out
something they'd like to use it for. :-)
Fixed Functor to report __name__ and __doc__ of the function properly
instead of raising an AttributeError.
Changed 'always' functors to accept any arguments when called, rather
than only 0 args.
Rcurry has been changed to raise an error if applied to a callable which
uses keyword arguments, or takes a variable number of arguments. Use
curry for those cases, since it allows more explicit control of partial
application. This change was made because it was difficult to establish
non-surprising behavior for rcurry in these situations.
First removed closure function, since Python 2.1 supports them directly, then
put it back, when the winds shifted against nested scopes.
Converted test suite to use PyUnit. Wrote more tests.