What's TOTALLY COMPELLING about Ruby over Python?
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Fri Aug 22 11:54:56 EDT 2003
On Mon, 18 Aug 2003 16:22:01 -0400, rumours say that "John Roth"
<newsgroups at jhrothjr.com> might have written:
>All of the Ruby collections implement a .each method, which is essentially
>a version of the Visitor pattern. If I want to do something to every element
>in a list or a dict (or any kind of collection,) all I have to do is say
>something
>like (using Python syntax):
>
>collectObj.each(<method name>)
You can do similar things in Python, just wrap your collection in a
class. Check this module:
http://www.sil-tec.gr/~tzot/python/predicates.py
See the test cases after the line
if __name__ == "main":
Does this work for you? Esp. the do method.
PS I don't believe that the my final test labeled "Tricky" works, but
RSN I'm going to work on it :)
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
More information about the Python-list
mailing list