When we do:
print '%s %d' % ('hello', 10)
what special method is being invoked internally within the string-
format-specifier?
format() invokes format__
print invokes __str__
I'm basically trying to make sense of:
raise TypeError('urkle urkle %s' % list(dictionary))
<=> raise TypeError('urkle urkle %s' % [ key1, val1, key2, val2 ]
So, the % operator reads the format specifier and notices %s and
therefore calls __str__ in the list class to figure out how to represent
[ key1, val1, key2, val2 ].
However what if I use %d? How do the other format specs work?
--
https://mail.python.org/mailman/listinfo/python-list