Possible Duplicate:
python: class override “is” behavior
I am trying to override the is operator, so that I could do something like
if tom is writer:
print 'tom is writing'
elif tom is programmer:
print 'tom is programming'
Is this possible in python?
As far as I know, you can’t override ‘is’ because it tests whether two objects are the same object by comparing their memory addresses (i.e. pointer comparison). You probably want to override ‘==’ by implementing tom’s
__eq__method.