Planet Python
Follow
LernerPython blog, from Reuven Lerner: Python __mod__: Modulo for numbers, interpolation for str
The % in Python, on numbers, is modulo:x = 10
y = 3
x % y # 1
x.__mod__(y) # same thing, 1But str uses __mod__ for interpolation:s = 'Hi, %d'
s % y # 'Hi, 3'
s.__mod__(y) # Same thing, 'Hi, 3'Same operator, same magic method — but totally different.