In article <200312031748.hB3Hm5504233 at c-24-5-183-134.client.comcast.net>, Guido van Rossum <guido at python.org> wrote: > > A minor correction: the Voodoo approach handles fine method calls by > > defining a __call__ method in the Voodoo class; [...] > > > > lambda x: x.startswith("text") > > This works fine as: > > Voodoo().startswith("text") > > Hm. But the whole point of Voodoo is that the resulting object has a > __call__ method that evaluates the expression for a given argument. > How do you do that? (I suppose you can do it if you don't do > chaining, but I like the chaining.) I think you would need two kinds of voodoo. extract.attr could expand to lambda x: x.attr (or something similar via __call__ methods) but method.startswith could expand to lambda *args: lambda x: x.startswith(*args) Then you could do sort(stringlist, key=method.count("kibo")) or whatever. Obviously this doesn't allow you to easily express e.g. methods of attributes, but beyond a certain level of complexity you should be using separate defs anyway. -- David Eppstein http://www.ics.uci.edu/~eppstein/ Univ. of California, Irvine, School of Information & Computer Science
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4