Skip to content

Instantly share code, notes, and snippets.

@pranithan-kang
Created March 29, 2024 07:29
Show Gist options
  • Save pranithan-kang/cdc830d2c57ae86dd23da77dfa00d715 to your computer and use it in GitHub Desktop.
Save pranithan-kang/cdc830d2c57ae86dd23da77dfa00d715 to your computer and use it in GitHub Desktop.
dataclass experimental
from dataclasses import dataclass
@dataclass
class A:
id: int
def __eq__(self, other):
return self.id == other.id
@dataclass(eq=True)
class AA(A):
attr: str
l: list = []
aa1 = AA(1, 'a')
aa2 = AA(1, "b")
assert aa1 == aa2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment