Forum: Poser Python Scripting


Subject: Useful Code Snippets

structure opened this issue on Jun 27, 2019 ยท 94 posts


structure posted Wed, 12 August 2020 at 7:49 PM Forum Coordinator

Use a tuple as a dictionary key

theDict = { (0,1,2,3) : "This is a test" }
print(theDict[ tuple(range(0,4))])

which gives this output
This is a test

keys=theDict.keys()
test=(0,3)
for item in test:
    for key in keys:
        if item in key:
        print(theDict[tuple(key)])


which also gives this output
This is a test

Locked Out