[Tutor] Improving My Simple Game Code for Speed, Memory and Learning
wolfrage8765 at gmail.com
Mon Jan 12 23:54:58 CET 2015
> I haven't looked carefully at your code but there's always a smell in
> Python when you see structure[x][y]. Can you change the grid so you
> always write something like:-
> for row in grid:
> for cell in row:
> I say this as I'm all for short term pain, long term gain, especially
> when it's guaranteed to eliminate "list index out of range" errors.
I think in this case I have to say no. I purposely wrote those "proc" or
"procedurally" style functions to ensure that access to the grid in this
way would result in the correct output from id, and to test that it
worked as expected.
However there are other places in my code where I think I can eliminate
this smell such as the new function that drops the non-zero values.
More information about the Tutor