[Tutor] Improving My Simple Game Code for Speed, Memory and Learning

Dave Angel davea at davea.name
Sat Jan 3 22:42:46 CET 2015


On 01/03/2015 04:22 PM, WolfRage wrote:
> On 01/03/2015 06:58 AM, Dave Angel wrote:
>> To transpose a grid, you want to use the zip() function.
>>      self.transposed_grid = zip(*self.grid)
> I see this gives me a list that is the column. Thus it solves the column
> iteration problem, because now I can feed it to my checking and
> elimination functions that take a slice.
> Thanks!
> Implementing now.

I suspect you want instead:

     self.transposed_grid = list( zip(*self.grid) )

in Python 3.4.  zip gives an iterable for python 3.x, while it gave a 
list in python 2.x

This is what I meant by "untested."

-- 
DaveA


More information about the Tutor mailing list