The iter method should return an iterator object, but you are returning a list object. Use def __iter__(self): return iter(self. _values) instead to fix this.
From the documentation for object. __iter (my highlighting): This method is called when an iterator is required for a container. This method should return a new iterator object that can iterate over all the objects in the container.
The __iter__ method should return an iterator object, but you are returning a list object. Use def __iter__(self): return iter(self. _values) instead to fix this.
From the documentation for object. __iter__ (my highlighting): This method is called when an iterator is required for a container. This method should return a new iterator object that can iterate over all the objects in the container.
Thanks Torsten Marek. I'll paste my new version that works below. – orokusaki Feb 1 '10 at 22:42.
Def __iter__(self): return iter(self. _values) Or a more generic: def __iter__(self): for x in self. _values: yield x.
Meh, it stays anyway. :) – Lennart Regebro Feb 1 '10 at 22:42 Ah, thanks. Your second version helps me understand better too.
Isn't the second version a generator? Does it perform differently than the first version? – orokusaki Feb 1 '10 at 22:44 BTW +1 vote.
Thanks. – orokusaki Feb 1 '10 at 22:44 @orokusaki: It is a generator, indeed. I'd expect it to be a bit slower, but I haven't tested it.
The important difference is that you can do things to x before yielding it. – Lennart Regebro Feb 1 '10 at 22:47.
Iter__ needs to return an iterator, not a list. Try this: def __iter__(self): return iter(self. _values) You could also do: def __iter__(self): for val in self.
_values: yield val But I can't really think of a reason you'd need to do that instead of using iter().
1 vote for you too. Sometimes answers come too fast here. – orokusaki Feb 1 '10 at 22:44.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.