Python hash() can't handle long integer?

Posted by Xie on Stack Overflow See other posts from Stack Overflow or by Xie
Published on 2010-04-22T02:14:33Z Indexed on 2010/04/22 2:23 UTC
Read the original article Hit count: 231

Filed under:
|
|

I defined a class:

class A:
    ''' hash test class
    >>> a = A(9, 1196833379, 1, 1773396906)
    >>> hash(a)
    -340004569

    This is weird, 12544897317L expected.
    '''
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d

    def __hash__(self):
        return self.a * self.b + self.c * self.d

Why, in the doctest, hash() function gives a negative integer?

© Stack Overflow or respective owner

Related posts about python

Related posts about hash