← Quiz: Magic Methods and Properties: all 10 questions
Quiz: Magic Methods and Properties · Question 9 of 10
When is @staticmethod the right choice?
When is @staticmethod the right choice?
- A.When the method needs to change object attributes
- B.When the method must create a new object of the class
- C.When the helper needs neither the object nor the class, but belongs with the class logically
- D.When the method should run automatically
Answer & explanation
Correct answer: When the helper needs neither the object nor the class, but belongs with the class logically
A staticmethod is a plain function placed inside the class namespace.
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 →