On 26/08/24 23:00, Dan Sommers via Python-list wrote:
On 2024-08-26 at 20:42:32 +1200,
dn via Python-list wrote:
and if we really want to go over-board:
RIGHT_JUSTIFIED = ">"
THOUSANDS_SEPARATOR = ","
s_format = F"{RIGHT_JUSTIFIED}{S_FIELD_WIDTH}{THOUSANDS_SEPARATOR}"
or (better) because r
On 2024-08-26 at 20:42:32 +1200,
dn via Python-list wrote:
> and if we really want to go over-board:
>
> >>> RIGHT_JUSTIFIED = ">"
> >>> THOUSANDS_SEPARATOR = ","
> >>> s_format = F"{RIGHT_JUSTIFIED}{S_FIELD_WIDTH}{THOUSANDS_SEPARATOR}"
>
> or (better) because right-justification is the default
On 26/08/24 03:12, Gilmeh Serda via Python-list wrote:
Subject explains it, or ask.
This is a bloody mess:
s = "123456789" # arrives as str
f"{f'{int(s):,}': >20}"
' 123,456,789'
With recent improvements to the expressions within F-strings, we can
separate the string from the form
On Sun, 25 Aug 2024 15:12:20 GMT Gilmeh Serda via Python-list wrote:
>Subject explains it, or ask.
>
>This is a bloody mess:
>
s = "123456789" # arrives as str
f"{f'{int(s):,}': >20}"
>' 123,456,789'
>
f"{s:>20}"
--
https://mail.python.org/mailman/listinfo/python-list
On 2024-08-25 16:12, Gilmeh Serda via Python-list wrote:
Subject explains it, or ask.
This is a bloody mess:
s = "123456789" # arrives as str
f"{f'{int(s):,}': >20}"
' 123,456,789'
You don't need to format twice; you can combine them:
>>> s = "123456789"
>>> f'{int(s): >20,}'
'
On Sun, 25 Aug 2024 15:12:20 GMT Gilmeh Serda via Python-list wrote:
>Subject explains it, or ask.
>
>This is a bloody mess:
>
s = "123456789" # arrives as str
f"{f'{int(s):,}': >20}"
>' 123,456,789'
>
Oops.. forgot comma
f"{int(s):>20,}"
--
https://mail.python.org/mailman/li