I have checked some idea and the reason, is which investigated below for this problem... "Too many values to unpack" Exception (Stefano Borini's explanation)
But here I am iterating through a list as a comprehension list and move the result to a list...!
So the number of the inputs reads the number of the output variable, i.e. tempList
...
Then, what is wrong with the process?!
def DoProcess(self, myList):
tempList = []
tempList = [[x,y,False] for [x,y] in myList]
return tempList
Edit 1: myList
is a list of lists, just like [[x1, y1], [x2, y2], [x3, y3], [x4 y4]]
.
class Agent(object):
def __init__(self, point = None):
self.locationX = point.x
self.locationY = point.y
def __iter__(self):
return self
def __next__(self):
return [self.locationX, self.locationY]
def __getItem__(self):
return [self.locationX, self.locationY]
def GenerateAgents(self, numberOfAgents):
agentList = []
while len(agentList) < numberOfAgents:
point = Point.Point()
point.x = random.randint(0, 99)
point.y = random.randint(0, 99)
agent = Agent(point)
agentList.append(agent)
return agentList
def DoProcess(self, myList):
tempList = []
tempList = [[x[0],x[1],False] for x in myList]
return myList
And each Point
has two attribute as locationX
and locationY
...