From 7c54564abbc23a53a4303a79618c4e0df85c49ca Mon Sep 17 00:00:00 2001 From: apo77yon <126520850+apo77yon@users.noreply.github.com> Date: Sat, 1 Apr 2023 15:36:56 -0700 Subject: [PATCH] Create decorators.md --- web2-projects/decorators.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 web2-projects/decorators.md diff --git a/web2-projects/decorators.md b/web2-projects/decorators.md new file mode 100644 index 0000000..c2bef00 --- /dev/null +++ b/web2-projects/decorators.md @@ -0,0 +1,29 @@ +## decorators + +
+ +### `@dataclass` + +go from: + +``` +class Person(): + def __init__(self, first_name, last_name, age, job): + self.first_name = first_name + self.last_name = last_name + self.age = age + self.job = job +``` + +to: + +``` +from dataclasses import dataclass + +@dataclass +class Person: + first_name: str + last_name: str + age: int + job: str +```