@dataclass — the class shape AI ships in every modern Python project — step 8 of 9
Write a Task dataclass with three fields:
title: str(required)priority: intwith default1tags: listwithfield(default_factory=list)
Use the @dataclass decorator. Don't write __init__ by hand —
let the decorator generate it.
Then create two tasks, append a tag to one of them, and print both to verify the lists are independent.
Expected output:
Task(title='ship', priority=1, tags=['urgent'])
Task(title='clean inbox', priority=3, tags=[])
⌘↵ runs the editor.read, then continue.
Write a Task dataclass with three fields:
title: str(required)priority: intwith default1tags: listwithfield(default_factory=list)
Use the @dataclass decorator. Don't write __init__ by hand —
let the decorator generate it.
Then create two tasks, append a tag to one of them, and print both to verify the lists are independent.
Expected output:
Task(title='ship', priority=1, tags=['urgent'])
Task(title='clean inbox', priority=3, tags=[])
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.