When to use Python special methods?

Posted by bodacydo on Stack Overflow See other posts from Stack Overflow or by bodacydo
Published on 2010-03-11T20:20:36Z Indexed on 2010/03/11 20:24 UTC
Read the original article Hit count: 419

Filed under:

I know that classes can implement various special methods, such as __iter__, __setitem__, __len__, __setattr__, and many others. But when should I use them? Can anyone describe typical scenarios when I would want to implement them and they would simplify programming in Python?

Thanks, Boda Cydo.

© Stack Overflow or respective owner

Related posts about python