I have a Python object with attributes a
, b
, c
.
I still use old string formatting, so I'd normally print these manually:
print 'My object has strings a=%s, b=%s, c=%s' % (obj.a, obj.b, obj.c)
Lately, my strings have been getting super long, and I'd much rather be able to simply pass the object into a string format function, something like:
print 'My object has strings a=%a, b=%b, c=%c'.format(obj)
However, the syntax is incorrect. Is this possible?