Movatterモバイル変換
[0]ホーム
[Python-ideas] Negative hexes
Antoine Pitrousolipsis at pitrou.net
Mon Dec 5 18:15:32 CET 2011
On Sun, 4 Dec 2011 11:13:26 +1000Nick Coghlan <ncoghlan at gmail.com> wrote:> On Sun, Dec 4, 2011 at 3:07 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:> >> This is because Python's integers are not limited to 32 bits or 64 bits. If> >> you read PEP 237, you'll see that this was one of the hardest differences> >> between ints and longs to be resolved. You'd have to include an infinite> >> number of leading 'F' characters to format a negative long this way...> >> > That's a fair point :)>> Random thought... could we use the integer precision field to fix> *that*, by having it indicate the intended number of bytes in the> integer?>> That is, currently:>> >>> "{:.4x}".format(31)> Traceback (most recent call last):> File "<stdin>", line 1, in <module>> ValueError: Precision not allowed in integer format specifierThis is so poorly discoverable that I don't think it's worth it.Guido's approach looks sufficient to me.RegardsAntoine.
More information about the Python-ideasmailing list
[8]ページ先頭