You can still do filters, just do it yourself
You can still do filters, just do it yourself
Posted Jan 22, 2025 19:08 UTC (Wed) by NYKevin (subscriber, #129325)Parent article: A revamped Python string-formatting proposal
I'm not sure why filters would need to be part of the PEP in the first place. You can define a custom type that overrides __or__() and __ror__() with the desired semantics. As far as I can tell, that's already legal in f-strings today, and there is no obvious reason it would fail to work in t-strings.
Of course, whether that's a good idea is neither here nor there. I'm just saying you don't need language support to make it happen.
