I recently came across a very interesting talk by James Powell on YouTube (LINK, around 12 minutes into the video). In his PyData talk, he states that "[...] The Python data model is a means by which you can implement protocols [...]". He relates his statement to the use of dunder-methods (like __init__
, __repr__
, etc.).
I've been programming for quite a while with Python, but I haven't come across POP. The video didn't really define what it is. What is POP in Python actually and how is it used in practice?
__repr__
,__cmp__
etc. as interface implementations. Any object that has__cmp__
can be compared - in Java, you'd make the object implement theComparable
interface.