1 year ago

#74555

test-img

PSC

List of object and string as a key in dictionary

I have a key which is a list of an object and a string. Example: [Obj, "test"]. I want to convert this into a key for a dictionary in python -> {[Obj, "test"]: value}

I have seen that you could convert the list into a string and use that as a key: key = "[Obj, 'test']". But the problem with that is that I cannot access the methods for Obj.

Is there a way to achieve this while conserving the Object's properties?

python

dictionary

key

0 Answers

Your Answer

Accepted video resources