Re: Slicing Arrays in this way

2007-05-03 Thread Tobiah
John Machin wrote: > On May 3, 8:55 am, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> On Wed, 02 May 2007 15:03:24 -0700, Tobiah wrote: >> >>> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) >>> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] >> Wow! That's impressive. What version of Python are you usin

Re: Slicing Arrays in this way

2007-05-03 Thread Michael Hoffman
John Machin wrote: > On May 3, 10:21 am, Michael Hoffman <[EMAIL PROTECTED]> wrote: >> Tobiah wrote: >> >>> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) >>> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] >> That's not an array, it's a list. See the array module for arrays >> (fixed-length, unlike varia

Re: Slicing Arrays in this way

2007-05-02 Thread Steven D'Aprano
On Wed, 02 May 2007 16:01:05 -0700, John Machin wrote: > The OP has already confessed. Don't rub it in. Sorry, I sent my comment before I received his confession. -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing Arrays in this way

2007-05-02 Thread James Stroud
Tobiah wrote: > > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] > > Here's one I use: def elegant_solution(alist): i = iter(alist) return [[j, i.next()] for j in i] py> elegant_solution(range(14)) [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10,

Re: Slicing Arrays in this way

2007-05-02 Thread John Machin
On May 3, 10:21 am, Michael Hoffman <[EMAIL PROTECTED]> wrote: > Tobiah wrote: > > > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] > > That's not an array, it's a list. See the array module for arrays > (fixed-length, unlike variable-length lists). You

Re: Slicing Arrays in this way

2007-05-02 Thread Michael Hoffman
Tobiah wrote: > > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] That's not an array, it's a list. See the array module for arrays (fixed-length, unlike variable-length lists). -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing Arrays in this way

2007-05-02 Thread Ian Clark
Yeah, having an elegant_solution() function would solve soo many of my problems. ;) Ian -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing Arrays in this way

2007-05-02 Thread John Machin
On May 3, 8:55 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 02 May 2007 15:03:24 -0700, Tobiah wrote: > > > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] > > Wow! That's impressive. What version of Python are you using? When I try > it, I ge

Re: Slicing Arrays in this way

2007-05-02 Thread Steven D'Aprano
On Wed, 02 May 2007 15:03:24 -0700, Tobiah wrote: > > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] Wow! That's impressive. What version of Python are you using? When I try it, I get this: >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) Traceback (most r

Re: Slicing Arrays in this way

2007-05-02 Thread Tobiah
I'm a retard. Disregard. -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing Arrays in this way

2007-05-02 Thread Tobiah
John Machin wrote: > On May 3, 8:03 am, Tobiah <[EMAIL PROTECTED]> wrote: >> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) >> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] >> > > What is your definition of "elegant"? What about other dimensions of > code quality like "robust" and "fast"? > > What hav

Re: Slicing Arrays in this way

2007-05-02 Thread Tobiah
Matimus wrote: > On May 2, 3:03 pm, Tobiah <[EMAIL PROTECTED]> wrote: >> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) >> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] >> >> -- >> Posted via a free Usenet account fromhttp://www.teranews.com > seq = range(1,11) seq > [1, 2, 3, 4, 5, 6, 7, 8,

Re: Slicing Arrays in this way

2007-05-02 Thread John Machin
On May 3, 8:03 am, Tobiah <[EMAIL PROTECTED]> wrote: > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] > What is your definition of "elegant"? What about other dimensions of code quality like "robust" and "fast"? What have you tried? Here's one possibili

Re: Slicing Arrays in this way

2007-05-02 Thread Matimus
On May 2, 3:03 pm, Tobiah <[EMAIL PROTECTED]> wrote: > >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) > [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] > > -- > Posted via a free Usenet account fromhttp://www.teranews.com >>> seq = range(1,11) >>> seq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> zip( seq[0::2],se

Slicing Arrays in this way

2007-05-02 Thread Tobiah
>>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list