On Wed, 08 Mar 2006 11:29:29 -0000, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Wed, 08 Mar 2006 11:00:09 +0000, Matt Hammond wrote: > >>> 4: Can I avoid the dummy counter i in the for loop and do something >>> like: >>> yz=[y[:-1].x-y[1:].x] >> >> yz = [e.x for e in y] >> yz.reverse() > > I don't think that's what the O.P. actually wants. He seems to have > misused slicing syntax as some sort of weird replacement for a for loop. > > Of course, I could be wrong. Hmmm, rereading, I think you're right ... and I think I'm confused too :-) Attempt #2: yz = [ (y1.x - y2.x) for (y1,y2) in zip(y[:-1], y[1:]) ] Frankly, a for loop with an index would probably be easier to read :) Matt -- | Matt Hammond | R&D Engineer, BBC Research & Development, Tadworth, Surrey, UK. | http://kamaelia.sf.net/ | http://www.bbc.co.uk/rd/ -- http://mail.python.org/mailman/listinfo/python-list