[Pywikipedia-l] __hash__ method of Link object in pywikibot

Liangent liangent at gmail.com
Mon Apr 20 06:06:51 UTC 2009


we need this method, and the following bad behavior goes against python's
design:
>>> from pywikibot import *
>>> Link.__hash__
<slot wrapper '__hash__' of 'object' objects>
>>> Link.__eq__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Link' has no attribute '__eq__'
>>> Link.__cmp__
<unbound method Link.__cmp__>
>>> hash(Link('1'))
26872464
>>> hash(Link('1'))
26872400
>>> hash(Link('1'))
26872464
>>> Link('1')==Link('1')
Found 1 wikipedia:zh processes running, including this one.
True
>>> hash(Link('1'))==hash(Link('1'))
False
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikimedia.org/pipermail/pywikipedia-l/attachments/20090420/8beb8ba5/attachment.htm 


More information about the Pywikipedia-l mailing list