3 ms·
And, that's easy to fix: '%s' % (foo,) Ugly, but you can be safe if you don't mind three more bytes of source code.
by jrockway 15y ago
And, that's easy to fix:
'%s' % (foo,)
Ugly, but you can be safe if you don't mind three more bytes of source code.
- irahul 15y agoOr '{}'.format(foo). Personally, I have never faced this issue as: 1. I know/control the input while string formatting. 2 String-formatting tuple comes up rarely.
- jrockway 15y agoI format tuples for debugging on a regular basis, but tend to just wrap every arg to the format string in repr, so this never comes up.
- TheNewAndy 15y agoThis won't solve the immediate problem, but if you use "%r" instead of "%s", python will do the repr() for you.