I\'m writing a class which encapsulates any arbitrary object, including simple types. I want the \"is\" keyword to operate on the encapsulated value, such as this behavior:<
is itself cannot be overloaded, but you may be interested in other "Reflection" magic methods which may be suitable for your use case (since you are looking at this thread):
__instancecheck__(self, instance)Checks if an instance is an instance of the class you defined (e.g.isinstance(instance, class).
__subclasscheck__(self, subclass)Checks if a class subclasses the class you defined (e.g.issubclass(subclass, class)).