¿Cómo se implementa la palabra clave 'is' en Python?

... elis palabra clave que se puede usar para la igualdad en cadenas.

>>> s = 'str'
>>> s is 'str'
True
>>> s is 'st'
False

Probé ambos__is__() y__eq__() Pero no funcionaron.

>>> class MyString:
...   def __init__(self):
...     self.s = 'string'
...   def __is__(self, s):
...     return self.s == s
...
>>>
>>>
>>> m = MyString()
>>> m is 'ss'
False
>>> m is 'string' # <--- Expected to work
False
>>>
>>> class MyString:
...   def __init__(self):
...     self.s = 'string'
...   def __eq__(self, s):
...     return self.s == s
...
>>>
>>> m = MyString()
>>> m is 'ss'
False
>>> m is 'string' # <--- Expected to work, but again failed
False
>>>

Respuestas a la pregunta(10)

Su respuesta a la pregunta