Iteration over two sequences

Henrik Holm news+0409 at henrikholm.com
Wed Jan 12 13:17:36 EST 2005


John Lenton <jlenton at gmail.com> wrote:

> > def dotproduct(a, b):
> >    psum = 0
> >    for i in range(len(a)):
> >        psum += a[i]*b[i]
> >    return psum
> 
> for this particular example, the most pythonic way is to do nothing at
> all, or, if you must call it dotproduct,
> >>> from Numeric import dot as dotproduct

Downloading, installing, and getting to know numerical modules for
Python is mext on my list :).  However, I was under the impression that
Numarray is preferred to Numeric -- is that correct?  Are these two
competing packages?  (Hopefully this is not flame war bait...)

-- 
"On some great and glorious day the plain folks of the land will reach
in their heart's desire at last and the White House will be adorned by
a downright moron."
                             -H.L. Mencken (1880-1956) American Writer 



More information about the Python-list mailing list