Python operator overloading and __init__ method -


i learning python mark lutz books 5th edition right working out oop in python. there concept of operator overloading. okay operator overloading , and how use process objects using e.g. arithmetic operators etc. driving me nuts is mentioning __init__ method constructor in python representative of operator overloading class saying 1 of methods belonging operator overloading family methods. or perception wrong considering lines , how operator overloading method!?.here reference topic.

i think __init__ mentioned alongside operator methods because it's double-underscored special method are. think it's misleading call them "operator overloading methods", since many special methods have nothing operators.

i'd suggest reading official python documentation on topic, __foo__ type methods call "special methods". of them indeed related operators, many others related converting between types (__str__, __bool__, __int__, etc.) or implementing builtin functions (__len__, __iter__, __format__, __hash__, etc.). others run indirectly, __get__, __set__ , __delete__ methods implement descriptor protocol. i'd group __init__ , __new__ in indirectly run methods, rather ones implement operators.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -