Skip to content

Instantly share code, notes, and snippets.

@tal95shah
Created July 10, 2018 13:48
Show Gist options
  • Select an option

  • Save tal95shah/713cd9c8f87e5d4ea929dd4b16432bb6 to your computer and use it in GitHub Desktop.

Select an option

Save tal95shah/713cd9c8f87e5d4ea929dd4b16432bb6 to your computer and use it in GitHub Desktop.
Python 3.7 using dataclasses way to code employee class
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