Closed tekknolagi closed 3 years ago
Oops, I forgot a test for changing behavior in this commit and you merged faster than I could amend my commit D: I'll file a subsequent PR.
Ahh, thanks for catching that. That's obviously a much better way to handle it.
I'm not sure I understand your point about the string module?
Kind of like this:
import string
class C:
foo = "bar"
f = string.Formatter()
instance = C()
result = f.format("{0.foo}", instance)
assert result == "bar"
There's get_field
and get_value
, etc: https://docs.python.org/3.7/library/string.html#string.Formatter
_asdict
is not public API fornamedtuple
.You may want to consider using the built-in
string
module, which implements this kind of.0
/.foo
formatting.