← Quiz: Magic Methods and Properties: all 10 questions
Quiz: Magic Methods and Properties · Question 6 of 10
Which decorator writes <=, and = for you from eq and lt?
Which decorator writes <=, > and >= for you from __eq__ and __lt__?
- A.functools.total_ordering
- B.functools.wraps
- C.dataclasses.dataclass only
- D.staticmethod
Answer & explanation
Correct answer: functools.total_ordering
total_ordering fills in the remaining comparison methods.
Can you get the rest right without peeking?
Take the timed Quiz: Magic Methods and Properties quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →