Included optional arguments

This commit is contained in:
Brandon Rozek 2020-04-30 23:18:42 -04:00
parent 51978ba13c
commit d9942249cd

View file

@ -13,7 +13,7 @@ from dataclasses import dataclass
@dataclass
class Person:
name: str
age: int
age: int = 0
```
Usage:
@ -27,3 +27,5 @@ print(p)
Person(name='Bob', age=20)
```
To make an attribute have a default value, add it after the type declaration like I have with `age`.