What is the docstring convention in Python for the following "magic" class methods:

  • __str__
  • __unicode__
  • __repr__

Should I add docstrings for these? If yes, what should they say (for each)?

  • 1
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    Commented Nov 24, 2015 at 4:42

1 Answer 1


I wouldn't add docstrings; they'll never meaningfully differ from the python stdlib docs relating to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.