I have the following code:
neig = []
for _ in xrange(number):
r = random.randint(0,self._tam-1)
s = random.randint(0,self._tam-1)
neig.append([r,s, self.deltaC(r, s)])
I am trying to get rid of the for loop using map
, a generator or something to optimize the build of the list. I've checked this answer, but in my case I need to give values to the elements.
Would it be possible to use a generator and delay the call to deltaC
? I think using map
is not possible because the body of the loop has more than one statement.