Bug in the documentation (?)
Pawel Oleksik
oleksik at awa.mat.agh.edu.pl
Sat Sep 9 08:22:12 EDT 2006
Hi, Snake Tamers
According to http://www.python.org/doc/2.4.1/lib/typesseq-strings.html (and
next releases):
"""
The conversion types are:
Conversion Meaning Notes
[...]
x Unsigned hexadecimal (lowercase). (2)
X Unsigned hexadecimal (uppercase). (2)
"""
But actually:
Python 2.4.1 (#1, Apr 10 2005, 22:30:36)
[GCC 3.3.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> '%x' % -123456
'-1e240'
so it is a _signed_ hexadecimal.
However, sometimes it would be convinient to get the unisgned conversion
(especially, since id(..) can return a negative value).
This way is rather clumsy:
>>> '%x' % (id('abcd')+0x100000000)
'b7b75380'
Do you see any better solution?
p.o.
More information about the Python-list
mailing list