Skip to content

Instantly share code, notes, and snippets.

@Tishka17
Created September 14, 2021 09:21
Show Gist options
  • Save Tishka17/8d5f0ef0ac42c7bf7e3959458dace9f3 to your computer and use it in GitHub Desktop.
Save Tishka17/8d5f0ef0ac42c7bf7e3959458dace9f3 to your computer and use it in GitHub Desktop.
Incorrect str inheritance
class MyString(str):
def __init__(self, data):
self.data = data
def append(self, other):
self.data += other
def __str__(self):
return self.data
a = MyString("hello")
print(a)
print(a + " world")
a.append(" world")
print(a)
print(a + " again")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment