Kreso a écrit :
I am writing an application that essentially calculates set of numbers,
say N1, N2, ..., where they can be calculated by several different algorithms. (One should be able to choose the algorithm at run time.) In each algorithm one starts from a set of functions, say f1, f2, ...,
which are then transformed into some other functions g1(f1, f2, ..),
g2(f1, f2, ...), ... , then maybe transformed once more and result is obtained by evaluating final functions. I can naturally think about this as a collection of transformation
blocks, which have functions as input and output, and which can be
put together to get the final results. However, I am not sure
how to program this, especially since one cannot subclass function
type.

Nope, but you can write your own callable types:


class functor(object):
    def __call__(self):
        print "%s called" % self

(snip)

I seem to be confused by the fact that I would like to somehow treat
algorithms as objects

Strategy pattern anyone ?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to