Steven Bethard wrote: > I've seen at least one reasonable example of this kind of thing: > > http://mail.python.org/pipermail/python-list/2004-October/245432.html
the code he's referring to doesn't seem to use that construct anymore, so it's not obvious what "dejavu.icontains" etc really is, but assuming they're strings, the following is a reasonable lambda-free alternative: class xforms: def icontains(self, x, y): return x + " Like '%" + y[1:-1] + "%'" def icontainedby(self, x, y): # icontainedby body goes here instead of in a separate function def istartswith(self, x, y): return x + " Like '" + y[1:-1] + "%'" def iendswith(self, x, y): return x + " Like '%" + y[1:-1] + "'" def ieq(self, x, y): return x + " = " + y def now(self): return "Now()" def today(self): return "DateValue(Now())", def year(self, x): return "Year(" + x + ")" def dispatch(self, tag, *args): return getattr(self, tag)(*args) here's another "reasonable example", btw: http://groups-beta.google.com/group/comp.lang.python/msg/11462b89a490a6ac this too could be rewritten to use a class (combined with re.sub and a callback, most likely). </F> -- http://mail.python.org/mailman/listinfo/python-list