3 ms·
The author is right in that you should use iterators and generators whenever they are a elegant solution. I do not think, that you should use nested functions
by allendoerfer 12y ago
The author is right in that you should use iterators and generators whenever they are a elegant solution.
I do not think, that you should use nested functions that often, as already mentioned, they are hard to test.
You get more readable and testable code, when you put the code in a new method or in another class instead. You end up with less lines per method and you can pass the data explicitly, getting rid of the self.
- Walkman 12y ago> they are hard to test. I don't get this. Do you write test for every private methods in your class? That's totally unnecessary.
- chris_mahan 12y agoI don't test (2 + 2) to make sure it equals 4.