Created
March 29, 2024 07:29
-
-
Save pranithan-kang/cdc830d2c57ae86dd23da77dfa00d715 to your computer and use it in GitHub Desktop.
dataclass experimental
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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