Created
July 10, 2018 14:40
-
-
Save tal95shah/137608d0aab8ee0691acf67740cb2d5c to your computer and use it in GitHub Desktop.
Inheritance used in dataclasses.
This file contains hidden or 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 | |
| from typing import Any | |
| @dataclass | |
| class Customer(object): | |
| customer_id: Any = 2.0 | |
| name: str = "" | |
| @dataclass | |
| class CustomerExtended(Customer): | |
| address: str = "" | |
| customer_id: int = 1 | |
| if __name__ == '__main__': | |
| ce = CustomerExtended() | |
| print("ce:{}".format(ce)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment