[Tutor] Improving My Simple Game Code for Speed, Memory and Learning
Steven D'Aprano
steve at pearwood.info
Sun Jan 4 00:46:00 CET 2015
On Sat, Jan 03, 2015 at 06:10:31PM -0500, WolfRage wrote:
> On 01/03/2015 04:42 PM, Dave Angel wrote:
> >self.transposed_grid = list( zip(*self.grid) )
> This results in the same thing with or with out the list() wrapper. Using
> Python 3.4.0 (default, Apr 11 2014, 13:05:11)
> [GCC 4.8.2] on linux
I don't think so. Perhaps you need to look a little more closely?
py> grid = [(1,2), (3,4), (5,6)]
py> zip(*grid)
<zip object at 0xb7bf238c>
py> list(zip(*grid))
[(1, 3, 5), (2, 4, 6)]
Zip objects are not lists, although they can often (but not always) be
used where you are expecting a list.
--
Steve
More information about the Tutor
mailing list