473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

hex(id(...)) and negative id's, 6 questions

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.
obj=object()
hex(id(obj)) /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' obj <object object at 0xbf59d3b8> hex(abs(id(object)))

'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.

--
PrePEP: Builtin path type
http://people.nl.linux.org/~gerrit/c.../pep-xxxx.html
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Jul 18 '05 #1
0 1067

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Ron | last post by:
Hi all I'm deciding whether to use the PK also as an account number, invoice number, transaction number, etc that the user will see for the respective files. I understand that sometimes a...
12
by: Sathyaish | last post by:
Please forgive my nescience. I have worked extensively on Win32 but I am only familiar with C and C++. Lately, I have been practicing C from K&R. Here 're a few doubts I have written in the...
29
by: foker | last post by:
I have this problem where I have 2 text files, one with student name, id#, # of courses and course #, the second file has course name and course number. I want to make a multidimensional array that...
2
by: Janis Papanagnou | last post by:
I want to use the 'cloneNode(true)' method to duplicate table rows with all its subnodes. Cloning the complete tree is very handy but I must be cautious because of the unique IDs and names that...
6
by: =?Utf-8?B?ZGlhdG9tQG5ld3Nncm91cC5ub3NwYW0=?= | last post by:
Hello, I have a data entry windows form. One of the text boxes allows the user to enter a string. I need this text box to only allow users to type in a negative integer value (e.g. -1, -2,...
0
by: prognoob | last post by:
i am using g++ compiler i am getting negative thread id on using pthread_self() function... i tried doing both int tid = pthread_self() and pthread_t tid = pthread_self() i still get negative...
1
by: Bruce | last post by:
<Sorry this question is not tied to C#, but I could not find a good forum that tackles such questions> Hi I am trying to come up with a good hashing function for user IDs in my app. The user...
9
by: kimiraikkonen | last post by:
Hi, Here is 2 questions: 1) I declared some global hotkeys located inside Windows API follows as: Private Const MOD_ALT As Integer = 1 Private Const MOD_CONTROL As Integer = 2 Private Const...
2
by: John Doe | last post by:
Hi, I am currently developping a software where items that will be inserted into a graphical widget ListCtrl are first defined in static array as shown below : enum TUiContext {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.