Created
March 4, 2019 12:15
-
-
Save kaisugi/c3560750b7a24ce51ad7961d975ab546 to your computer and use it in GitHub Desktop.
Python 3.7で正式追加された @DataClass のサンプル
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(order=True) | |
class Human: | |
age: int | |
name: str | |
boy = Human(2, "suzuki") | |
girl = Human(3, "misaka") | |
print(boy) # Human(age=2, name='suzuki') | |
print(boy == girl) # False | |
print(boy < girl) # True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment