Pārlūkot izejas kodu

fix default list in dict

Bastien Sevajol 7 gadus atpakaļ
vecāks
revīzija
b9199e131b
2 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 2 2
      sandbox/engulf/simulation.py
  2. 1 1
      synergine2/xyz.py

+ 2 - 2
sandbox/engulf/simulation.py Parādīt failu

@@ -30,10 +30,10 @@ class EngulfSubjects(XYZSubjects):
30 30
         super().append(p_object)
31 31
 
32 32
         if isinstance(p_object, Cell):
33
-            self.cell_xyz.get(p_object.position, []).append(p_object)
33
+            self.cell_xyz.setdefault(p_object.position, []).append(p_object)
34 34
 
35 35
         if isinstance(p_object, Grass):
36
-            self.grass_xyz.get(p_object.position, []).append(p_object)
36
+            self.grass_xyz.setdefault(p_object.position, []).append(p_object)
37 37
 
38 38
 
39 39
 class Engulf(XYZSimulation):

+ 1 - 1
synergine2/xyz.py Parādīt failu

@@ -232,7 +232,7 @@ class XYZSubjects(Subjects):
232 232
                 str(p_object),
233 233
             ))
234 234
 
235
-        self.xyz.get(p_object.position, []).append(p_object)
235
+        self.xyz.setdefault(p_object.position, []).append(p_object)
236 236
 
237 237
 
238 238
 class XYZSimulation(BaseSimulation):