Skip to content

Conversation

@alexbarcelo
Copy link

@alexbarcelo alexbarcelo commented Dec 20, 2021

When obj is a tuple, this raise yields a TypeError given that the formatting is not resolved.

The proper way of doing this is by ensuring that a tuple is being used for string formatting (in particular, a single element tuple).

And, on the way there, it's much better to use %r in this context, just in case obj is a complex object and has a non-trivial __str__ method --while the __repr__ method should be simpler. In a lot of scenarios this change is imperceptible, in others improves log messages a lot.

When `obj` is a tuple, this raise yields a TypeError given that the formatting is not resolved.

The proper way of doing this is by ensuring that a tuple is being used for string formatting (in particular, a single element tuple).

And, on the way there, it's much better to use `%r` in this context, just in case `obj` is a complex object and has a non-trivial `__str__` method --while the `__repr__` method should be simpler. In a lot of scenarios this change is imperceptible, in others improves log messages a lot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant