Created
June 19, 2023 14:17
-
-
Save dominikb1888/ec65cbbbc7037d467c59a29a51aa875c to your computer and use it in GitHub Desktop.
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
| # @dataclass | |
| class Person: | |
| """A custom data type that represents data for a person.""" | |
| def __init__(self, given_name: str, family_name: str, age: int, address: str): | |
| self.given_name = given_name | |
| self.family_name = family_name | |
| self.age = age | |
| self.address = address | |
| def __repr__(self): | |
| # Loop through all attributes of our object and put them into a list of strings | |
| # <attribute name> = ' <attribute_value> ' | |
| # attribute_value may be with or without quotes (numeric types) | |
| return f"Person(given_name='{self.given_name}', family_name='{self.family_name}', age={self.age}, address='{self.address}')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment