Files
pgames-manager/frontend/tests/fixtures/dunders.py
T
mrleo1nidandClaude Sonnet 5.5 e1c596288e
CI / frontend (push) Failing after 18s
CI / backend (push) Failing after 35s
feat: random generators, frozenset and __hash__/__iter__/__getitem__/__contains__ in Ren'Py python
renpy.random/random get choices, sample, randrange and Random(seed); frozenset, iter and hash
are builtins. User classes may define __hash__ (dict keys), __iter__, __getitem__ and
__contains__; the converter accepts them instead of rejecting the whole class, which
removes the Perk/Skill/Status wall in SaintlyCorruption.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 02:55:44 +03:00

36 lines
669 B
Python

class Perk:
def __init__(self, key):
self.key = key
def __hash__(self):
return hash(self.key)
def __eq__(self, other):
return self.key == other.key
class Bag:
def __init__(self, items):
self.items = items
def __iter__(self):
return iter(self.items)
def __getitem__(self, i):
return self.items[i]
def __contains__(self, x):
return x in self.items
table = {}
table[Perk("a")] = 1
table[Perk("a")] = 2
result_size = len(table)
result_value = table[Perk("a")]
bag = Bag([3, 4, 5])
result_loop = [x * 2 for x in bag]
result_item = bag[1]
result_in = 4 in bag
result_out = 9 in bag