Author doerwalter
Recipients
Date 2003-01-10.16:36:24
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
class tuple2(tuple):
·  def __getitem__(self, index):
·  ·  return 2*tuple.__getitem__(self, index)

class str2(str):
·  def __getitem__(self, index):
·  ·  return chr(ord(str.__getitem__(self, index))+1)

print filter(lambda x: x>1, tuple2((1, 2)))
print filter(lambda x: x>"a", str2("ab"))

this prints:
(2,)
bc

i.e. the overwritten __getitem__ is ignored in the
first case, but honored in the second.
History
Date User Action Args
2007-08-23 14:09:57adminlinkissue665835 messages
2007-08-23 14:09:57admincreate