Explained the pattern for special methods compatibility.

This commit is contained in:
Aymeric Augustin 2013-04-19 09:53:19 +02:00
parent 5306285ce2
commit bfe25de429
1 changed files with 3 additions and 0 deletions

View File

@ -317,6 +317,9 @@ Division
def __idiv__(self, other): # Python 2 compatibility def __idiv__(self, other): # Python 2 compatibility
return type(self).__itruediv__(self, other) return type(self).__itruediv__(self, other)
Special methods are looked up on the class and not on the instance to reflect
the behavior of the Python interpreter.
.. module: django.utils.six .. module: django.utils.six
Writing compatible code with six Writing compatible code with six