Hash of class from instance

2005-02-02 Thread Joakim Storck
Hello, Is there any way that I can find the hash value of a class from an instance? >>> class A: ... pass ... >>> a = A() >>> hash(A) 10782976 >>> hash(a) 12251904 >>> What I want is a function that returns the value of 'hash(A)': > a.getHashOfClass() 10782976 Is this possible? /Joakim --

Hash of class from instance

2005-02-02 Thread Joakim Storck
Hello, Is there any way that I can find the hash value of a class from an instance? >>> class A: ... pass ... >>> a = A() >>> hash(A) 10782976 >>> hash(a) 12251904 >>> What I want is a function that returns the value of 'hash(A)': > a.getHashOfClass() 10782976 Is this possible? /Joakim --

Re: Hash of class from instance

2005-02-02 Thread Joakim Storck
Thanks! Not so strange I think, the hash values of classes will be used as keys in a dictionary that serve as an object pool. Sorry about the double posting, I got a 'server error' message the first time, so I figured it hadn't gone trhough. /Joakim -- http://mail.python.org/mailman/listinfo/p

Re: Hash of class from instance

2005-02-02 Thread Joakim Storck
So I guess it might be a little bit less unwise to use id() instead then... /Joakim -- http://mail.python.org/mailman/listinfo/python-list

Re: Hash of class from instance

2005-02-02 Thread Joakim Storck
Simply because it didn't occur to me. So now I have >>> class A: pass ... >>> d = {A:[A(),A(),A()]} >>> a = d[A].pop() >>> a <__main__.A instance at 0x00F09A58> >>> Thanks all! /Joakim -- http://mail.python.org/mailman/listinfo/python-list