RE: unzip function?

2012-02-02 Thread Prasad, Ramit
>>> If you understand what zip does, it should be obvious. >> >> Nobody likes to be told the thing they're confused about is trivial. >Nobody likes to be told to brush their teeth, eat their vegetables or clean >their room. Then they grow up and learn that life is full of things that you >do be

Re: unzip function?

2012-01-19 Thread Devin Jeanpierre
On Wed, Jan 18, 2012 at 6:20 PM, Steven D'Aprano wrote: > On Wed, 18 Jan 2012 11:20:00 -0500, Devin Jeanpierre wrote: > Nobody likes to be told to brush their teeth, eat their vegetables or > clean their room. Then they grow up and learn that life is full of things > that you do because you have t

Re: unzip function?

2012-01-18 Thread Steven D'Aprano
On Wed, 18 Jan 2012 11:20:00 -0500, Devin Jeanpierre wrote: > On Wed, Jan 18, 2012 at 10:27 AM, Steven D'Aprano > wrote: >>> That zip (*sorted... >>> >>> does the unzipping. >>> >>> But it's less than intuitively obvious. >> >> *shrug* >> >> If you understand what zip does, it should be obvious.

Re: unzip function?

2012-01-18 Thread Hrvoje Niksic
Neal Becker writes: > python has builtin zip, but not unzip > > A bit of googling found my answer for my decorate/sort/undecorate problem: > > a, b = zip (*sorted ((c,d) for c,d in zip (x,y))) > > That zip (*sorted... > > does the unzipping. > > But it's less than intuitively obvious. > > I'm thi

Re: unzip function?

2012-01-18 Thread Devin Jeanpierre
On Wed, Jan 18, 2012 at 10:27 AM, Steven D'Aprano wrote: >> That zip (*sorted... >> >> does the unzipping. >> >> But it's less than intuitively obvious. > > *shrug* > > If you understand what zip does, it should be obvious. Nobody likes to be told the thing they're confused about is trivial. It's

Re: unzip function?

2012-01-18 Thread Devin Jeanpierre
On Wed, Jan 18, 2012 at 10:31 AM, Rodrick Brown wrote: > Alec can you explain this behavior zip(*zipped)? Here's one way to think about it: If A is a matrix, zip(*A) returns the transpose of A. That is, the columns become rows, and the rows become columns. If you swap rows and columns, and then

Re: unzip function?

2012-01-18 Thread Chris Rebert
On Wed, Jan 18, 2012 at 7:31 AM, Rodrick Brown wrote: > On Wed, Jan 18, 2012 at 10:27 AM, Alec Taylor > wrote: >> >> http://docs.python.org/library/functions.html >> >>> x = [1, 2, 3] >> >>> y = [4, 5, 6] >> >>> zipped = zip(x, y) >> >>> zipped >> [(1, 4), (2, 5), (3, 6)] >> >>> x2, y2 = zip(*zip

Re: unzip function?

2012-01-18 Thread Benjamin Kaplan
On Wed, Jan 18, 2012 at 10:31 AM, Rodrick Brown wrote: > > > On Wed, Jan 18, 2012 at 10:27 AM, Alec Taylor > wrote: >> >> http://docs.python.org/library/functions.html >> >>> x = [1, 2, 3] >> >>> y = [4, 5, 6] >> >>> zipped = zip(x, y) >> >>> zipped >> [(1, 4), (2, 5), (3, 6)] >> >>> x2, y2 = zip

Re: unzip function?

2012-01-18 Thread Steven D'Aprano
On Wed, 18 Jan 2012 09:33:34 -0500, Neal Becker wrote: > python has builtin zip, but not unzip That's because zip is (almost) its own inverse. > A bit of googling found my answer for my decorate/sort/undecorate > problem: > a, b = zip (*sorted ((c,d) for c,d in zip (x,y))) That does a lot of

Re: unzip function?

2012-01-18 Thread Rodrick Brown
On Wed, Jan 18, 2012 at 10:27 AM, Alec Taylor wrote: > http://docs.python.org/library/functions.html > >>> x = [1, 2, 3] > >>> y = [4, 5, 6] > >>> zipped = zip(x, y) > >>> zipped > [(1, 4), (2, 5), (3, 6)] > >>> x2, y2 = zip(*zipped) > >>> x == list(x2) and y == list(y2) > True > Alec can you exp

Re: unzip function?

2012-01-18 Thread Alec Taylor
http://docs.python.org/library/functions.html >>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> zipped = zip(x, y) >>> zipped [(1, 4), (2, 5), (3, 6)] >>> x2, y2 = zip(*zipped) >>> x == list(x2) and y == list(y2) True -- http://mail.python.org/mailman/listinfo/python-list

Re: unzip function?

2012-01-18 Thread Alec Taylor
http://docs.python.org/library/zipfile.html ZipFile.extractall([path[, members[, pwd]]]) -- http://mail.python.org/mailman/listinfo/python-list