Re: [Tutor] Process list elements as consecutive pairs

2010-03-06 Thread Peter Otten
Rüdiger Wolf wrote: > I am trying to Process list elements as consecutive pairs into > consecutive pairs. > Any pythonic suggestions? > > listin = [1,2,3,4,5,6,7,8,9,10] > I want to process as consecutive pairs > 1,2 > 3,4 > 5,6 > 7,8 > 9,10 >>> listin = [1,2,3,4,5,6,7,8,9,10] >>> it = iter(lis

Re: [Tutor] Process list elements as consecutive pairs

2010-03-06 Thread Hugo Arts
On Fri, Mar 5, 2010 at 10:48 PM, Hugo Arts wrote: > > Except the OP requested pairs (1, 2), (3, 4), i.e. with no duplicate > elements. Here is a generator that does what you need: > > def pairs(seq): >    it = iter(seq) >    try: >        while True: >            yield it.next(), it.next() >    ex

Re: [Tutor] Process list elements as consecutive pairs

2010-03-05 Thread Hugo Arts
2010/3/5 Emad Nawfal (عمـ نوفل ـاد) : > > > Here is a general solution that I also took from the Tutor list some time > ago. It allows you to have consequences of (any) length. > def makeVectors(length, listname): > ...     """takes the length of the vector and a listname returns vectors""" >

Re: [Tutor] Process list elements as consecutive pairs

2010-03-05 Thread عمـ نوفل ـاد
On Fri, Mar 5, 2010 at 1:03 PM, Wayne Werner wrote: > On Fri, Mar 5, 2010 at 11:56 AM, Rüdiger Wolf < > rudiger.w...@throughputfocus.com> wrote: > >> Hi >> >> I am trying to Process list elements as consecutive pairs into >> consecutive pairs. >> Any pythonic suggestions? >> >> listin = [1,2,3,4

Re: [Tutor] Process list elements as consecutive pairs

2010-03-05 Thread Wayne Werner
On Fri, Mar 5, 2010 at 11:56 AM, Rüdiger Wolf < rudiger.w...@throughputfocus.com> wrote: > Hi > > I am trying to Process list elements as consecutive pairs into > consecutive pairs. > Any pythonic suggestions? > > listin = [1,2,3,4,5,6,7,8,9,10] > I want to process as consecutive pairs > 1,2 > 3,

Re: [Tutor] Process list elements as consecutive pairs

2010-03-05 Thread greg whittier
On Fri, Mar 5, 2010 at 12:56 PM, Rüdiger Wolf < rudiger.w...@throughputfocus.com> wrote: > I am trying to Process list elements as consecutive pairs into > consecutive pairs. > Any pythonic suggestions? > > listin = [1,2,3,4,5,6,7,8,9,10] > I want to process as consecutive pairs > 1,2 > 3,4 > 5,6

[Tutor] Process list elements as consecutive pairs

2010-03-05 Thread Rüdiger Wolf
Hi I am trying to Process list elements as consecutive pairs into consecutive pairs. Any pythonic suggestions? listin = [1,2,3,4,5,6,7,8,9,10] I want to process as consecutive pairs 1,2 3,4 5,6 7,8 9,10 Thanks Rudiger ___ Tutor maillist - Tutor@p