David Isaac wrote:
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]:
Numarray is the future, Numeric is the "past",
This statement is not obviously true. See the recent discussion on the
developer lists. (Search for Numeric3.)
Alan Isaac
I stand corrected. Sorry
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]:
> Numarray is the future, Numeric is the "past",
This statement is not obviously true.
See the recent discussion on the developer lists.
(Search for Numeric3.)
Alan Isaac
--
http://mail.python.org/mailman/listin
My example is somewhat flawed because it assigns a and b the values of the
iteration - so in the end, b is 'c', and only setting a to [1,2] will show
your results.
Use c and d for the variables in the for-statments, and things work as
expected.
--
Regards,
Diez B. Roggisch
--
http://mail.python
"It's me" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I tried this and I got:
> [(1, 'a'), (2, 'b'), (3, 'c')]
> But if I change:
> a=[1,2]
> I got:
> [(1, 'c')]
> Why is that? I thought I should be getting:
> [(1, 'a'),(2,'b')]
> ?
Cut and paste the actual input and output
Henrik Holm wrote:
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 import dot as dotp
> 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...)
Numeric's dot uses, if
Henrik Holm wrote:
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 import dot as dotp
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
I tried this and I got:
[(1, 'a'), (2, 'b'), (3, 'c')]
But if I change:
a=[1,2]
I got:
[(1, 'c')]
Why is that? I thought I should be getting:
[(1, 'a'),(2,'b')]
?
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> zip or izip is your friend:
>
> import i
> 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 dot product. The straight-ahead
> C-like way of doing it would be:
>
> def dotproduct(a, b):
>psum = 0
>
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 overlooking?
>
> Check the itertools recipes in the lib
"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 overlooking?
Check the itertools recipes in the library documentation.
--
http://mail.python.org/mailman
"Henrik Holm" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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
zip or izip is your friend:
import itertools
a = [1,2,3]
b = ['a', 'b', 'c']
for a,b in itertools.izip(a, b):
print a, b
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
14 matches
Mail list logo