On 21Apr2021 10:14, Paul Moore <p.f.moore@gmail.com> wrote:
On Wed, 21 Apr 2021 at 09:01, Serhiy Storchaka <storchaka@gmail.com> wrote:
Do we need support of more standard conversions? Do we want to support custom conversions (registered globally as encodings and error handlers). re.escape, html.escape and shlex.quote could be very useful in some applications.
That appeals to me just because I like generic features in general, but I'm not sure there are sufficient benefits to justify the complexity for what would basically be a small convenience over calling the function directly.
I frequently use str.format and str.format_map to produce strings from formats provided as configuration; in those methods I can't use arbitrary functions (injection, anyone?) For example: fstags ls -o format-string-here ... to produce a particular listing format. I would _frequently_ like to be able to provide custom conversions. At present I'm using elaborate hacks based on __getattr__ etc to recognise things like this: '{x} is {x_lc} in lowercase' where the _lc suffix is caught and a value computed from "x". Custom conversions would let me use this: '{x} is {x!lc} in lowercase' just by registering 'lc' as a conversion from my code. Chaining then per Serhiy's other suggestion would bring a fair amount of power. Cheers, Cameron Simpson <cs@cskk.id.au>