Path: csiph.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Lawrence =?iso-8859-13?q?D=FFOliveiro?= Newsgroups: comp.lang.python Subject: Formatted Integer With Specified Number Of Digits Date: Sun, 19 Oct 2025 07:26:44 -0000 (UTC) Organization: A noiseless patient Spider Lines: 33 Message-ID: <10d23rk$2bc2b$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 19 Oct 2025 07:26:45 +0000 (UTC) Injection-Info: dont-email.me; posting-host="82af3b06475bb41c8d62950873271a3d"; logging-data="2469963"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C30rVYe6rOjds27d2+27B" User-Agent: Pan/0.164 (Kupiansk) Cancel-Lock: sha1:vxidbWAxupr87Axf4tygIqjw9sg= Xref: csiph.com comp.lang.python:197567 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: >>> format(2, "#03x") '0x2' (Not what I want) >>> format(2, "#0.3x") Traceback (most recent call last): File "", line 1, in format(2, "#0.3x") ~~~~~~^^^^^^^^^^^^ ValueError: Precision not allowed in integer format specifier >>> "{:#03x}".format(2) '0x2' (Not what I want) >>> "{:#0.3x}".format(2) Traceback (most recent call last): File "", line 1, in "{:#0.3x}".format(2) ~~~~~~~~~~~~~~~~~^^^ ValueError: Precision not allowed in integer format specifier Why not?