Builder Pattern
Peter Otten
__peter__ at web.de
Thu Feb 2 07:50:33 EST 2006
> I have converted another example of strategy which I prefer to the 2
> described earlier, here it is:
>
> class FindMinima:
> def algorithm(self):raise NotImplementedError
When most of your code does nothing in a pompous way that is a sure sign
that you are heading in the wrong direction. Here's a translation into
python:
def least_squares(line):
return 1.1, 2.2
def newtons_method(line):
return 3.3, 4.4
def bisection(line):
return 5.5, 6.6
def conjugate_gradient(line):
return 3.3, 4.4
def test():
solver = least_squares
print solver((5.5,5.5))
solver = bisection
print solver((5.5,5.5))
test()
Peter
More information about the Python-list
mailing list