A Universe Set
skip at pobox.com
skip at pobox.com
Mon Oct 16 10:21:11 EDT 2006
>> - the wildcard object, which compares equal to everything else
Paul> class MatchAny(object):
Paul> def __cmp__(self,other):
Paul> return 0
Paul> wild = MatchAny()
...
You're at the mercy of the comparison machinery implemented by individual
classes. Executing this script (using any of Python 2.3 through what's
currently in the SVN repository):
import datetime
class MatchAny(object):
def __cmp__(self,other):
return 0
wild = MatchAny()
print wild == datetime.datetime.now()
print datetime.datetime.now() == wild
print wild != datetime.datetime.now()
print datetime.datetime.now() != wild
yields
False
False
True
True
Skip
More information about the Python-list
mailing list