🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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__?

  1. A.functools.total_ordering
  2. B.functools.wraps
  3. C.dataclasses.dataclass only
  4. 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 →