Practice ยท 2 of 2
Class decorator: auto-properties
Implement @dataclassish โ a class decorator that, for every attribute annotated in the class body (use __annotations__), synthesizes:
- an __init__ accepting exactly those fields as keyword-or-positional args in declaration order, assigning each
- a __repr__ as Name(field=repr, ...) in declaration order
- an __eq__ comparing type and all field values (False for other types)
The class may define its own __init__ โ in that case LEAVE it alone and only add repr/eq if missing.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Decorator Engineering