testModule.py:
Код: Выделить всё
class testClass:
async def test(self):
r = DataSet()
for i in range(0, 10):
r.Tables.append(Table())
r.Tables[i].Rows.append(dict[int, int]())
r.Tables[i].Rows[0][0] = 0
Код: Выделить всё
class Table:
Rows: list[dict[str, Any]] = []
class DataSet:
Tables: list[Table] = []
Код: Выделить всё
class testClass:
async def test(self):
r = DataSet()
for i in range(0, 10):
r.Tables.append(Table())
r.Tables[i].Rows.append(dict[int, int]())
r.Tables[i].Rows[0][0] = 0
Код: Выделить всё
@app.get("/test")
async def test(instance: Annotated[testClass, Depends()]):
res = await instance.test()
return res

Почему второй экземпляр таблицы уже содержит элементы, даже если я их еще не добавлял?
Подробнее здесь: https://stackoverflow.com/questions/786 ... -in-python