equivalent of NULL or OM in Python

Steve Holden sholden at holdenweb.com
Fri Feb 16 15:48:52 CET 2001


"Steve Holden" <sholden at holdenweb.com> got too enthusiastic, and wrote
without checking:

> Evaluation for a particular value of x then comes down to:
>
> >>> poly = [4, 4, 3]
> >>> r = 0
> >>> x = 2
> >>> for p in range(len(poly)):
> ...  r = r + (x^p)*poly[p]
> ...
> >>> r
> 20

Woops, make that:

>>> for p in range(len(poly)):
...  r = r + (x**p)*poly[p]
...  print "p:", p, "r:", r
...
p: 0 r: 4
p: 1 r: 12
p: 2 r: 24

Got carried away and used the wrong power operator. Bitwise xor might have
been a little confusing here...

regards
 Steve




More information about the Python-list mailing list