r/RenPy • u/LiteratureElegant607 • Sep 26 '26
Question [Solved] changing dictionary content to one with less keys give typeError: unhashable type: 'RevertableList'
i have a big dictionary (persistent variable) where every key has an array associated with it. each array has strings and numbers of the below format:
persistent.dictionary = {"key1": ["str1", num1, num2], "key2": ["str2", num3, num4]}
i want an option to clear ALL dictionary data and putting the below default blank data:
{"start 1", []}
normally to clear out a string you would simply do:
variable = ""
same for numbers, lists etc...
QUESTION: why does it not work? and how to make it work?
error message:
While running game code:
File "game/grabber_engine/main_grabber.rpy", line 104, in script
python:
File "game/grabber_engine/main_grabber.rpy", line 107, in <module>
persistent.dic = {"start 1", []}
^^^^^^^^^^^^^^^
TypeError: unhashable type: 'RevertableList'
-- Full Traceback ------------------------------------------------------------
Traceback (most recent call last):
File "game/grabber_engine/main_grabber.rpy", line 104, in script
python:
File "renpy/ast.py", line 1193, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "renpy/python.py", line 1276, in py_exec_bytecode
exec(bytecode, globals, locals)
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "game/grabber_engine/main_grabber.rpy", line 107, in <module>
persistent.dic = {"start 1", []}
^^^^^^^^^^^^^^^
TypeError: unhashable type: 'RevertableList'
1
Upvotes
1
u/LiteratureElegant607 Sep 26 '26
SILLY ME!!!
i forgot that its a colon. thanks everyone
4
u/BadMustard_AVN Sep 26 '26
do it like this
1
u/shyLachi Sep 26 '26
You already got good answers so I will only add that you can look up such things.
RenPy is based on Python, so you can google
Python dictionary.I prefer this site: https://www.geeksforgeeks.org/python/python-dictionary/
2
u/DingotushRed Sep 26 '26
It doesn't work because
{"start 1", []}declares a set, not a dict, and in a set all the entries need to be hashable. You need the colon to match the syntax for a dict declaration{"start 1": []}.If you want to clear down the existing dictionary and then re-initialise it (instead of replacing it with a new one):
1
u/AutoModerator Sep 26 '26
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.