great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

Double check implementation of pattern= argument

Open machow opened this issue 5 months ago • 0 comments

The pattern= argument in format methods (e.g. .fmt_number()) substitutes in the formatted value in a template. The template expects {x} as the placeholder. It looks like the substitution is done sometimes using the .replace() method.

Let's look at the implementations of pattern to see whether it might benefit from using .format(x=...). It could be that .replace() was used because .format() errors for unused template variables. E.g.

# errors
s = "{x} {y}".format(x = 1)

So it could be .replace() is totally fine!

machow avatar Jun 13 '25 15:06 machow