I am just starting to learn Python, mostly by going through the examples
in Dive Into Python and by playing around.
Quite frequently, I find the need to iterate over two sequences at the
same time, and I have a bit of a hard time finding a way to do this in a
"pythonic" fashion. One example is a
Richard Brodie <[EMAIL PROTECTED]> wrote:
> "Henrik Holm" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> > I suppose I could also use a lambda here -- but is there a different,
> > efficient, and obvious solution that I'm over
John Lenton <[EMAIL PROTECTED]> 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
with a one-liner as well, with
lines = popen('executable').readlines()
without closing the file object?
Thanks,
Henrik Holm
--
http://mail.python.org/mailman/listinfo/python-list