Skip to content

Instantly share code, notes, and snippets.

@qiuyujx
Created May 2, 2022 12:12
Show Gist options
  • Save qiuyujx/c5fe3044ad15697b3bde59bfdfadfdef to your computer and use it in GitHub Desktop.
Save qiuyujx/c5fe3044ad15697b3bde59bfdfadfdef to your computer and use it in GitHub Desktop.
python_dataclass_person_normal.py
class Person:
def __init__(self, firstname, lastname, age):
self.firstname = firstname
self.lastname = lastname
self.age = age
def __repr__(self):
return f"Person(firstname='{self.firstname}', lastname='{self.lastname}', age={self.age})"
def __eq__(self, other):
return self.firstname == other.firstname and \
self.lastname == other.lastname and \
self.age == other.age
def greeting(self):
print(f'Hello, {self.firstname} {self.lastname}!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment