New submission from Cheryl Sabella <[email protected]>:
>From the doc
>(https://docs.python.org/3/library/string.html#format-specification-mini-language):
> The '_' option signals the use of an underscore for a thousands separator for
> floating point presentation types and for integer presentation type 'd'. For
> integer presentation types 'b', 'o', 'x', and 'X', underscores will be
> inserted every 4 digits. For other presentation types, specifying this option
> is an error.
>>> '{0:_}'.format(123456789)
'123_456_789'
>>> '{0:x}'.format(123456789)
'75bcd15'
>>> '{0:x_}'.format(123456789)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid format specifier
What am I doing wrong? I read the doc as saying that using `type` of `x` would
result in the `_` separator to be inserted every 4 characters, so I was
expecting the output to be '75b_cd15'.
Thanks!
----------
messages: 313330
nosy: csabella
priority: normal
severity: normal
status: open
title: Underscore in str.format with x option
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33013>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com