Question:
Why don't I get an exception message when formatting the message with %s but I do with format?
Fails:
>>> Exception('foo %s', 'bar').message
''
Works:
>>> Exception('foo {}'.format('bar')).message
'foo bar'
Any explanation why it fails on %s?
Your syntax for the %-substitution in Exception is incorrect. You need to use % to specify the replacement string:
>>> Exception('foo %s' % 'bar').message
'foo bar'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With