G
Gerrit
Hi,
in my own classes, I usually implement __repr__ with something like:
hex(id(obj))
....in order to simulate the behaviour of built-in types.
However, since I upgraded to Fedora Core 1 and Linux Kernel
2.4.22-1.2163.nptl, id(obj) is usually negative. Why is it negative?
Still, hex() returns a positive number when passed a negative argument. Why?
I can see that it will change, but why did it behave like this until 2.4?
Python 2.3.3 (#4, Feb 6 2004, 23:05:05)
[GCC 3.3.2 20040108 (Red Hat Linux 3.3.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information./home/gerrit/.pythonrc:1: FutureWarning: hex()/oct() of negative int
will return a signed string in Python 2.4 and up
#!/usr/bin/env python
'0xbf59d3b8''0x810ce20'
I see that obj still takes the positive part. It does not equal
hex(abs(...)). Why not? What is a signed string? And how do I keep behaving my
__repr__ like repr(obj) does in the future? How does repr(obj) bypass the
FutureWarning?
That are, let me count, 6 questions ;-)
Gerrit.
in my own classes, I usually implement __repr__ with something like:
hex(id(obj))
....in order to simulate the behaviour of built-in types.
However, since I upgraded to Fedora Core 1 and Linux Kernel
2.4.22-1.2163.nptl, id(obj) is usually negative. Why is it negative?
Still, hex() returns a positive number when passed a negative argument. Why?
I can see that it will change, but why did it behave like this until 2.4?
Python 2.3.3 (#4, Feb 6 2004, 23:05:05)
[GCC 3.3.2 20040108 (Red Hat Linux 3.3.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information./home/gerrit/.pythonrc:1: FutureWarning: hex()/oct() of negative int
will return a signed string in Python 2.4 and up
#!/usr/bin/env python
'0xbf59d3b8''0x810ce20'
I see that obj still takes the positive part. It does not equal
hex(abs(...)). Why not? What is a signed string? And how do I keep behaving my
__repr__ like repr(obj) does in the future? How does repr(obj) bypass the
FutureWarning?
That are, let me count, 6 questions ;-)
Gerrit.