Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Curious Omission In New-Style Formats Date: Mon, 11 Jul 2016 13:27:16 -0600 Lines: 16 Message-ID: References: <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> <5783c91e$0$1622$c3e8da3$5496439d@news.astraweb.com> <5783D63F.5040307@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de ujWudoy1S2fbrmvoebMkvAb+oVxT9+XZj6HpE1aTw84g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.076 X-Spam-Evidence: '*H*': 0.85; '*S*': 0.00; 'width': 0.07; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'meant': 0.22; 'occurs': 0.22; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message- id:@mail.gmail.com': 0.27; 'specify': 0.27; 'int': 0.33; 'case,': 0.34; "skip:' 20": 0.34; 'received:google.com': 0.35; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'format': 0.39; 'does': 0.39; 'subject:-': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'field': 0.60; 'challenge': 0.61; 'jul': 0.72; 'to:name:python': 0.84; 'improvement': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=MPMwQtxn2a4LQ1o+j4sMo6qVeZOcmz7iyoDLi+XHSZ0=; b=wEP4TNWyIcB60S5yQjLrPZypzMUgvORMB/rqD+3rwMgyAC09feOkEuTM4f7cW8jPA3 pYuRX8s82Qv8op6XTR4Xom1TGi1t7mEMi8ncY/NL+SdqgdUtJAphXXf1/l2T1iqaLbq5 su1iqPstnziJtDXTEyyJyjoEAEHA8f0iAj5HGOuFdTezl1tbYTGxQ3cNaSnF1HFc474z LPEdmg0v7hkEZ+xBGQgS2o1u3zBfHmnnAaCx5vzawP3umGKBXFJtifcdI594tYcjU4fI A0NqAS6NUbc2O0V+HxZdkvAN+SxxUZgfw6UVqHmD9G7OFUI3qAlzH0LVMrBZ/DzzDT4q nKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=MPMwQtxn2a4LQ1o+j4sMo6qVeZOcmz7iyoDLi+XHSZ0=; b=KEK2A52JiUG0X4QsLqY1xmecJK9FxNtO5UOHEdFW161hIr217YtX5USzh3i/XnFHqq o3Vslq6R/cQaLLNs0/LivPpoBq4j+a8ilZKbZXgGk0pDBGvkQeY5e5spfyLk1q5fu1s2 sRi5SxsW8wvPOF69vyQcyjxBVc0dvrQGslrGAjtDhiJ5lc1lcsXaZkbytNs0o/t+F4DF iSWqDIMxQRHbLDxKVe8CLaEcNNj2nH+Jze5NcGdDzr3TZ7khFuA09MI7RN12AiStiZpr SAmVPLiXwfPn3kJVSHuDKKLEA0O2gsMYm/sNl5SQI6hrs+i6kewDs8VGxBdgXw34GpKC 1zcw== X-Gm-Message-State: ALyK8tIhALuZYCDFHY6RgDcrUCT5ZjemSlPXUkq4fwlMX2dHIJ349UgLJrRrOsWSAuXIh5OOjuNJR3Bs0RPm7Q== X-Received: by 10.202.80.78 with SMTP id e75mr9823519oib.91.1468265275633; Mon, 11 Jul 2016 12:27:55 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> <5783c91e$0$1622$c3e8da3$5496439d@news.astraweb.com> <5783D63F.5040307@stoneleaf.us> Xref: csiph.com comp.lang.python:111287 On Mon, Jul 11, 2016 at 12:54 PM, Terry Reedy wrote: > In any case, I think it an improvement to say that '0x00123' has a field > width of 7 rather than a 'precision' of 5. > >>>> '{:#07x}'.format(0x123) # specifiy field width > '0x00123' >>>> "%#0.5x" % 0x123 # specify int precision > '0x00123' It occurs to me now that this does create a challenge if the format is meant to support negative numbers as well: >>> '%#0.5x' % -0x123 '-0x00123' >>> '{:#07x}'.format(-0x123) '-0x0123'