I had a thought about locale-specific formatting. Currently, when we want to do locale-specific formatting we use the locale module like this: >>> locale.format("%d", 12345, grouping=False) '12345' >>> locale.format("%d", 12345, grouping=True) '12,345' This makes it harder to use more than one locale at a time, or one which is different from the default. My thought was that we could specify a locale in the format specification mini-language and the parameter list of str.format, something like this: >>> loc = locale.getlocale() >>> "{0:@1}".format(12345, loc) '12345' >>> "{0:, at 1}".format(12345, loc) '12,345' ... >>> "UK says {value:,.1f at uk} and France says {value:,.1f at france}".format(value=12345, uk=uk_loc, france=france_loc) 'UK says 1,234.5 and France says 1 234,5' Comments?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4