Lookup table for unhashable in Python

后端 未结 4 1676
粉色の甜心
粉色の甜心 2021-01-12 19:45

I need to create a mapping from objects of my own custom class (derived from dict) to objects of another custom class. As I see it there are two ways of doing this:

4条回答
  •  醉话见心
    2021-01-12 20:16

    A simple solution seems to be to do lookup[id(myobj)] = myotherobj instead of lookup[myobj] = myotherobj. Any commente on this approach?

提交回复
热议问题