i got this list of objects with one item in it.
print self.parameters
print len(self.parameters)
for p in self.parameters:
print p
when i print out the list and len of the lsit i see the expected: one item.
But when looping over the lsit i also get a None item…!?
[<__main__.Parameter object at 0x00000000022D4828>]
1
<__main__.Parameter object at 0x00000000022D4828>
None
what is going on here?
(yes im sure, that the “None” output is from this print statement)
EDIT:
i was manipulating the list i was looping over:
print self.parameters
print len(self.parameters)
for p in self.parameters:
print p
(...)
self.parameters.append(<something that returned None>)
Don’t do this.
See Modifying list while iterating — basically, you shouldn’t modify something while iterating over it. You can make a copy if you want: