Created
July 10, 2018 13:48
-
-
Save tal95shah/713cd9c8f87e5d4ea929dd4b16432bb6 to your computer and use it in GitHub Desktop.
Python 3.7 using dataclasses way to code employee class
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 | |
| @dataclass | |
| class Employee(object): | |
| id: int | |
| name: str | |
| if __name__ == '__main__': | |
| emp = Employee(1,"Talha Gillani") | |
| emp2= Employee(2,"Syed Talha Gillani") | |
| print("emp:{}".format(emp)) | |
| print("emp2:{}".format(emp2)) | |
| print("emp == emp2:{}".format(emp == emp2)) | |
| print("emp != emp2:{}".format(emp != emp2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment