Graham Fawcett <[EMAIL PROTECTED]> wrote: >You could always use an "is-proper-subset-of" function, which is closer >to the intent of your algorithm. Using Jamitzky's very clever infix >recipe [1], you can even write it as an infix operator: > >#Jamitzky's infix-operator class, abbreviated >class Infix: > [ ... ] > ># define our is-proper-subset operator... >ips = Infix(lambda a, b: (a is not b) and (a in b)) > >>>> print 'a' |ips| 'a' >False >>>> print 'a' |ips| 'abc' >True
Unfortunately: >>> print 'abc' |ips| 'abc' False >>> print 'a'+'bc' |ips| 'abc' True Which might not be what you want. On the other hand, it's a simple fix: >>> ips = Infix(lambda a, b: (a != b) and (a in b)) >>> print 'a' |ips| 'abc' True >>> print 'a'+'bc' |ips| 'abc' False >[1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ | -- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- http://mail.python.org/mailman/listinfo/python-list