Django, for example, uses this code to cater for ValidationError
exceptions
>>> message = 'My name is %(name)s'
>>> params = {'name': 'George'}
>>> message %= params
>>> print(message):
'My name is George'
The only documentation I managed to find on %=
is here where it is called a modulus assignment operator
.
I really do not understand why it works with the old style formatting (%
) and I cannot understand how this will be used with the new style formatting (str.format()
).
Does the new style formatting render this code redundant?