roy at panix.com
Sun Feb 24 17:22:36 CET 2013
In article <mailman.2410.1361721167.2939.python-list at python.org>,
Chris Angelico <rosuav at gmail.com> wrote:
> The "dunder" methods ("d"ouble "under"score, leading and trailing),
> also called "magic methods", are the implementations of various
> special features. For instance, indexing foo is implemented using
> the __getitem__ method. Here's a list:
> You'll seldom, if ever, call these methods directly.
On the other hand, once you get into building your own classes, you will
often be *writing* them. The most common are __str__(), __repr__(), and
__unicode__(), and of course, __init__().
A quick look over my current project shows 471 classes, and I've defined:
Not to mention the boilerplate:
if __name__ == '__main__":
which shows up all over the place.
More information about the Python-list