ich habe folgenden Code:
Der Konstruktor bekommt u.a. eine Liste übergeben, die Gegenstand des Problems ist.
Ich habe 2 print Commandos mit #1 und #2 gekennzeichent. Beide Male wird die Liste ToUnPackAr ausgegeben (ein mal im Konstuktor, ein mal in der Methode unPacking(), welche durch activate(...) aufgerufen wird).
Bei #2 ist die Liste jedoch leer, wie in der Ausgabe zu sehen ist...Warum?
Danke für Tipps.
Code: Alles auswählen
class UnPacker(Process):
""" A process class unpacking LoadingUnits"""
def __init__(self, StationObj, ToUnPackAr):
""" Constructor:
Parameters:
@ Station (Station): The Station object where the storage is located
@ ToUnPack (list [LoadingUnit]): A list containing all LoadingUnits that must be unloaded"""
Process.__init__(self, name = "UnPacker")
self.StationObj = StationObj
self.ToUnPackAr = ToUnPackAr
activate(self, self.unPacking())
print "%s: #1 %s" %(now(),self.ToUnPackAr)
def unPacking(self):
""" unpacks LoadingUnits"""
def getToUnPack(Buff):
for x in Buff:
if x is Item:
return [x]
def spaceAvailable():
pass
if now() > 40:
print "%s: unpacker active at %s" %(now(), self.StationObj.name)
print "%s: #2 %s" %(now(), self.ToUnPackAr)
45: #1 [<__main__.LoadingUnit object at 0x02780FF0>, <__main__.LoadingUnit object at 0x02787030>, <__main__.LoadingUnit object at 0x02787050>,...
45: unpacker active at CM_MEXICO
45: #2 []