@RyanMarcus/

strintdict

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class StrIntDictWrapper:
  def __init__(self, int_dict):
    self.__old_dict = int_dict

  def __getitem__(self, key):
    return self.__old_dict[int(key)]

  def __setitem__(self, key, value):
    self.__old_dict[int(key)] = value

  def __delitem__(self, key, value):
    del self.__old_dict[int(key)]

  def keys(self):
    return (str(x) for x in self.__old_dict.keys())

  def items(self):
    return ((str(x), y) for x,y in self.__old_dict.items())


test = {1: "hello", 2: "world"}

test_mod = StrIntDictWrapper(test)

print(test_mod["1"])