Re: calculation on lists

2012-12-19 Thread Chris Kaynor
On Wed, Dec 19, 2012 at 4:38 AM, Vlastimil Brom wrote: > 2012/12/19 loïc Lauréote : > hi, > I > have a question, > is there a tool to calculate on list ? > > something like : > > >a= [1,1,1,1] > >b = [5,9,8,4] > >c = a+b*a > >print c > >[6,10,9,5] > > Thx > > == > > Hi, > for such simpler cas

Re: calculation on lists

2012-12-19 Thread Chris Kaynor
Chris On Wed, Dec 19, 2012 at 7:24 AM, loïc Lauréote wrote: > Thank for your answer, > > I found something allowing to avoid loops. > I use operator overloading. > > > import math > > class Vector: > def __init__(self, x=0, y=0): > self.x=x > self.y=y > def __eq__(self,

Re: calculation on lists

2012-12-19 Thread Tim Chase
On 12/19/12 09:24, loïc Lauréote wrote: >> is there a tool to calculate on list ? >> >> something like : >> >>> a= [1,1,1,1] >>> b = [5,9,8,4] >>> c = a+b*a >>> print c >>> [6,10,9,5] >> >> Thx >> >> == >> >> Hi, >> for such simpler cases, you may try list comprehensions and probably >> the zi

Re: calculation on lists

2012-12-19 Thread Vlastimil Brom
2012/12/19 loïc Lauréote : > hi, > I > have a question, > is there a tool to calculate on list ? > > something like : > >>a= [1,1,1,1] >>b = [5,9,8,4] >>c = a+b*a >>print c >>[6,10,9,5] > > Thx > > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, I guess, if you are interested in ef

Re: calculation on lists

2012-12-19 Thread Vlastimil Brom
2012/12/19 loïc Lauréote : hi, I have a question, is there a tool to calculate on list ? something like : >a= [1,1,1,1] >b = [5,9,8,4] >c = a+b*a >print c >[6,10,9,5] Thx == Hi, for such simpler cases, you may try list comprehensions and probably the zip(...) function >>> [a+b*a for a,b