Re: Formatted Integer With Specified Number Of Digits

Lawrence D’Oliveiro <[email protected]> Sun, 19 Oct 2025 21:39:17 -0000 (UTC)
Newsgroups comp.lang.python
Organization A noiseless patient Spider
Message-ID <[email protected]>
On Sun, 19 Oct 2025 10:01:16 -0400, songbird wrote:

> Lawrence D’Oliveiro wrote:
>>
>> Formatting an integer with 3 digits, excluding base specifier:
>>
>>     >>> "%#0.3x" % 2
>>     '0x002'
>>
>> No equivalent to this in any of the other ways that Python allows for
>> formatting:
>>
>> Why not?
> 

We already have printf-style formatting in Python, that’s what I was using 
above.