Python special methods can be implemented but code must be supplied. The above 4 keywords define additional sections in a class declaration (like public, private etc.). Typical sip file section is as follows:
class X { ... PyMethods: __str__ %MemberCode C++ code (no enclosing braces needed). Number and kind of arguments and return value depend on method (see specialPyMethod in sip.h). %End ... }
Within this section the following methods are legal:
__repr__, __str__, __cmp__, __hash__, __call__, __richcompare__
Within this section the following methods are legal:
__add__, __sub__, __mul__, __div__, __mod__, __divmod__, __pow__, __neg__, __pos__, __abs__, __nonzero__, __invert__, __lshift__, __rshift__, __and__, __xor__, __or__, __coerce__, __int__, __long__, __float__, __oct__, __hex__, __iadd__, __isub__, __imul__, __idiv__, __imod__, __ipow__, __ilshift__, __irshift__, __iand__, __ixor__, __ior__
Within this section the following methods are legal:
__len__, __add__, __mul__, __getitem__, __setitem__, __getslice__, __setslice__, __contains__, __iadd__, __imul__