Introducing Docstrings

By: Mark Mruss

Note: This article was first published the February 2008 issue of Python Magazine

Of all the tasks assigned to programmers, commenting code and writing documentation are among the most disliked. This article introduces you to Python’s documentation strings. While they won’t make commenting your code any more enjoyable, they will provide a systematic approach to doing it, as well as access to additional tools for documentation generation and testing.

[ad]

Continue reading Introducing Docstrings

Operator Overload! Learn how to change the behavior of equality operators.

By: Mark Mruss

Note: This article was first published the November 2007 issue of Python Magazine

While the equality operator works great on numbers and strings the fact the way it treats your custom objects really is not that useful. This article looks into overloading the equality operator so that you can easily compare your custom classes.

  1. Introduction
  2. Introducing the terms: operators and operator overloading
  3. A Quick Example of the Default Equality Operator
  4. Overloading the Equality Operator
  5. Telling Python that the Comparison has Not Been Implemented
  6. The Inequality Operator
  7. Dangers
  8. Conclusion

Continue reading Operator Overload! Learn how to change the behavior of equality operators.