Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dominikb1888/ec65cbbbc7037d467c59a29a51aa875c to your computer and use it in GitHub Desktop.

Select an option

Save dominikb1888/ec65cbbbc7037d467c59a29a51aa875c to your computer and use it in GitHub Desktop.
# @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