mirror of
https://github.com/autistic-symposium/web3-starter-py.git
synced 2025-05-17 14:10:21 -04:00
Create decorators.md
This commit is contained in:
parent
dee00907d8
commit
7c54564abb
1 changed files with 29 additions and 0 deletions
29
web2-projects/decorators.md
Normal file
29
web2-projects/decorators.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
## decorators
|
||||
|
||||
<br>
|
||||
|
||||
### `@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
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue