[PyQt] QTreeWidgetItem is not hashable in Py3

Barry Scott barry at barrys-emacs.org
Wed Mar 29 22:14:07 BST 2017


> On 29 Mar 2017, at 16:41, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> On 28 Mar 2017, at 5:31 pm, Sambhav Kothari <sambhavs.email at gmail.com> wrote:
>> 
>> Hi,
>> QTreeWidgetItem seems to be no longer hashable in py3.
>> 
>> I am using pyqt5.8.1 and py3.6. Is this a known issue?
> 
> Python considers a type to be unhashable if it has a comparison operator (which QTreeWidgetItem does).

int and str are hashable and have comparison operator.

Phil, I'm reacll I read a release notes of yours about this change.

I guess the only immutable property that you can hash is the memory address of the object.
Its text() property can be changed at any time. No to mention its list of parents. Would that be useful?

> Should should be able to implement __hash__() in a sub-class that does what you want.

I'd guess that its the text() and parent list that is interesting to hash and not the item itself.

Barry



More information about the PyQt mailing list