I am trying to get the math module to deal with degrees rather than
radians. (that it deals with radians for the angular functions like
sin() isn't mentioned in the docs, which was sort of an eyeopener :) I
can't find any info on doing this. I can convert from-to degrees in the
code calling the function, but that's a bit clunky. Any pointers to an
FM to R? :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE804+jd90bcYOAWPYRAt9KAKCuqeC4ozuXSaKZ5xY27Wv+k04QuQCcCrCZ
WyichPnKgXo+GaDdAebsaeU=
=h+vc
-----END PGP SIGNATURE-----
--
Jim Richardson
Anarchist, pagan and proud of it
http://www.eskimo.com/~warlock
Linux, from watches to supercomputers, for grandmas and geeks.
Radians are what trig is based on. Otherwise the formula for the area of
a circle would be 'A = 360r'; since when does a unit circle have an area
of 360 square units?
OTOH, `man 3 sin` on my system documents the sin() function of the C
math library _is_ documented as taking radians. On a POSIX system, this
is usually what is called by Ruby's Math.sin() method.
Can you just write an additional method like
def sin_d(deg)
Math.sin(deg * Math::PI / 180)
end
...and maybe even make it a method of the Math module itself?
Tim Hammerquist
--
For every problem, there is one solution which is simple, neat and wrong.
-- H. L. Mencken
Sorry for the confusion between languages here. The rest is still valid,
though.
Tim Hammerquist
--
Playing strip poker with an exhibitionist
somehow takes the challenge out of it.
-- Nick Smith, Metropolitan
Jim -
All the math routines I have ever dealt with use radians. In
30 years of dealing with this, in Fortran, C, C++ and Python, I
have found what works best for me is to use exclusively radians
internally and convert only where the user will see it - at the
GUI and with any text (not binary) files. (I think that this
works well, but may not be as natural with a command line program,
where the interface between the user and the program is so simple
to begin with.) In other words, I just consider the degrees/radians
conversion to be part of the interface between the user and the
program internals.
I find that it help to curse the Babylonian astronomers while
putting all the conversions in place.
- BOB
> > Radians are what trig is based on. Otherwise the formula for the area
> > of a circle would be 'A = 360r'; since when does a unit circle have an
> > area of 360 square units?
> >
Where do you get this from? A = pi * r^2?
> > OTOH, `man 3 sin` on my system documents the sin() function of the C
> > math library _is_ documented as taking radians. On a POSIX system,
> > this is usually what is called by Ruby's Math.sin() method.
> >
Maybe he's not on Unix?
You're right. Not enough coffee and too much time passed since college
trig. =) Correction:
: If trig were based on degrees, the following would be true for a
: unit circle:
:
: [ A = (180 * r^2) = 180 sq. units ]
: [ C = (360 * r) = 360 units ]
Thus:
"since when does a unit circle have an area of 180 sq. units?"
^^^^^^^^^^^^^
> > > OTOH, `man 3 sin` on my system documents the sin() function of
> > > the C math library _is_ documented as taking radians. On a POSIX
> > > system, this is usually what is called by Ruby's Math.sin()
> > > method.
>
> Maybe he's not on Unix?
My handy copy of the Turbo C++ 3.0 Library Reference manual from my
MS-DOS version of the software also documents sin() as taking a value in
radians. (C)1990. A.D. So this is far from new. One might say it's a
standard... A trig calculator's default setting doesn't dictate the
default of the world at large.
Furthermore, not all *nix systems are POSIX-compliant. And very few
POSIX-compliant systems are _completely_ compliant with the POSIX
standard.
My only intent in mentioning POSIX was that on most *nix systems (esp.
POSIX ones), you can #include<math.h> and compile and expect to call
a sin() function (that, btw, takes its argument in radians). Other
PC-oriented operating systems lack a standard math lib "out-of-the-box".
Tim Hammerquist
--
guru, n: a computer owner who can read the manual.
>Simon Foster graced us by uttering:
>> "Tim Hammerquist" <t...@vegeta.ath.cx> wrote:
>> > > Radians are what trig is based on. Otherwise the formula for the
>> > > area of a circle would be 'A = 360r'; since when does a unit
>> > > circle have an area of 360 square units?
>>
>> Where do you get this from? A = pi * r^2?
>
>You're right. Not enough coffee and too much time passed since college
>trig. =) Correction:
>
>: If trig were based on degrees, the following would be true for a
>: unit circle:
>:
>: [ A = (180 * r^2) = 180 sq. units ]
>: [ C = (360 * r) = 360 units ]
>
>Thus:
>
> "since when does a unit circle have an area of 180 sq. units?"
> ^^^^^^^^^^^^^
>
I think you need more coffee! Surely PI is "3 and a bit"! The
area of a unit circle is pi. How big do you make it?
>> > > OTOH, `man 3 sin` on my system documents the sin() function of
>> > > the C math library _is_ documented as taking radians. On a POSIX
>> > > system, this is usually what is called by Ruby's Math.sin()
>> > > method.
>>
>> Maybe he's not on Unix?
>
>My handy copy of the Turbo C++ 3.0 Library Reference manual from my
>MS-DOS version of the software also documents sin() as taking a value in
>radians. (C)1990. A.D. So this is far from new. One might say it's a
>standard... A trig calculator's default setting doesn't dictate the
>default of the world at large.
>
>Furthermore, not all *nix systems are POSIX-compliant. And very few
>POSIX-compliant systems are _completely_ compliant with the POSIX
>standard.
>
>My only intent in mentioning POSIX was that on most *nix systems (esp.
>POSIX ones), you can #include<math.h> and compile and expect to call
>a sin() function (that, btw, takes its argument in radians). Other
>PC-oriented operating systems lack a standard math lib "out-of-the-box".
>
>Tim Hammerquist
You're right here, I've never seen a trig call that didn't
expect the argument in rads.
--
Simon Foster
Somewhere in the West of England
The docstrings are the same on Windows and Macs <wink>:
>>> print math.sin.__doc__
sin(x)
Return the sine of x (measured in radians).
>>>
although-if-you-stick-with-1.5.2-you-won't-see-that-ly y'rs - tim
I think you missed my point. The OP was expressing his shock at Math.sin
accepting its argument in radians. I was painting a picture of what the
world would be like if trig were based on degrees instead.
Operating under the fairly certain assumption that (2*PI) radians = 360
degrees, I simply replace pi with 180 degrees in the classic geometric
functions. Thus:
A = PI * r^2
becomes:
A = 180 * r^2
So, for a unit circle whose radius is 1:
A = 180 * (1)^2
A = 180 * (1)
A = 180
--> 180 sq. units ?!?!?!
This is quite obviously ridiculous, and was intended so.
To satisfy your question, however, my value of pi, stored permanently in
my brain to six significant digits since Mr. Chatfield's calc class in
high school: 3.14159 ;)
> Simon Foster
> Somewhere in the West of England
Tim Hammerquist
Somewhere in the West of the United States
--
It's astonishing how much trouble one can
get oneself into, if one works at it.
-- Destruction, The Sandman
> My only intent in mentioning POSIX was that on most *nix systems (esp.
> POSIX ones), you can #include<math.h> and compile and expect to call
> a sin() function (that, btw, takes its argument in radians). Other
> PC-oriented operating systems lack a standard math lib "out-of-the-box".
>
BTW, this isn't really a unix-or-not issue, it's simply that mathematically,
the 'natural' form of all trig functions (their power series expansion)
requires their arguments to be expressed in radians: the period of sin(x) is
simply 2*pi, 6.1428..., whatever you want to call it. It's _not_ 360:
sin(0) == 0 ; sin(360) ~ 0.96.
Scientific calculators simply have a 'deg' mode which on the fly converts back
and forth between degree input and radians for internal work, but that's
simply a user convenience (because degrees are more conveninent for some
'everyday' use as angular measurement units).
Just a little detail.
Cheers,
f.
> I find that it help to curse the Babylonian astronomers while
> putting all the conversions in place.
Points...everything should be in points. There being 32 of them in a
circle, they are even binarily attractive. ;-)
--John (steer north by east 1/4 east, if you please) Baxter
On Sat, 04 May 2002 11:24:50 -0600,
Robert George Mayer <ma...@acm.org> wrote:
> Jim Richardson wrote:
>>
>>
>> I am trying to get the math module to deal with degrees rather than
>> radians. (that it deals with radians for the angular functions like
>> sin() isn't mentioned in the docs, which was sort of an eyeopener :) I
>> can't find any info on doing this. I can convert from-to degrees in the
>> code calling the function, but that's a bit clunky. Any pointers to an
>> FM to R? :)
>>
> Jim -
>
> All the math routines I have ever dealt with use radians. In
> 30 years of dealing with this, in Fortran, C, C++ and Python, I
> have found what works best for me is to use exclusively radians
> internally and convert only where the user will see it - at the
> GUI and with any text (not binary) files. (I think that this
> works well, but may not be as natural with a command line program,
> where the interface between the user and the program is so simple
> to begin with.) In other words, I just consider the degrees/radians
> conversion to be part of the interface between the user and the
> program internals.
>
> I find that it help to curse the Babylonian astronomers while
> putting all the conversions in place.
>
*chuckle* ok, sounds like the route to take. I don't have a lot of
programming experience, and python is my first "real" language in the
last 20 years. Assembly doesn't count in this context.
do you have any good curses in Babylonian to share? :P
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81B46d90bcYOAWPYRAmXfAJ9z4tItLXq/zVIq3Ef+uRIGgwJInACgxAkE
mZnnk1NR8xJrrfN8dWsQX+k=
=tXKl
On Sat, 04 May 2002 08:30:58 GMT,
Tim Hammerquist <t...@vegeta.ath.cx> wrote:
> Tim Hammerquist graced us by uttering:
>> Jim Richardson graced us by uttering:
>>> I am trying to get the math module to deal with degrees rather than
>>> radians. (that it deals with radians for the angular functions like
>>> sin() isn't mentioned in the docs, which was sort of an eyeopener :)
>>> I can't find any info on doing this. I can convert from-to degrees in
>>> the code calling the function, but that's a bit clunky. Any pointers
>>> to an FM to R? :)
>>
>> Radians are what trig is based on. Otherwise the formula for the area
>> of a circle would be 'A = 360r'; since when does a unit circle have an
>> area of 360 square units?
>>
>> OTOH, `man 3 sin` on my system documents the sin() function of the C
>> math library _is_ documented as taking radians. On a POSIX system,
>> this is usually what is called by Ruby's Math.sin() method.
>>
>> Can you just write an additional method like
>>
>> def sin_d(deg)
>> Math.sin(deg * Math::PI / 180)
>> end
>>
>> ...and maybe even make it a method of the Math module itself?
>
This is basically what I am now doing, (although yours is more elegant.)
I didn't realize that python basically called the C math function,
although that makes sense. I didn't think to check that. Thanks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81B7Ld90bcYOAWPYRAizKAKC4m5k2syn+c9xAA2M+mKmIQmZPpQCgrOzD
Lp6BYYh7ZLRLDPRmOe2pxDs=
=A8lE
I guess this whole furor shows how long it's been for me since I took
math at high school level :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81NrDd90bcYOAWPYRArmoAKCJK3bX5Q8wJKVf27Ivd0ggIZp9AQCdFJx9
UPU3O/FzMUekwp25yvTjTwU=
=tujK
Well, now that I have conquered elementry trig, I am now going to try
for simple python and figure out how to add the contents of a tuple to
the contents of another tuple...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81Ns9d90bcYOAWPYRAq+FAJ9tIc6yg7RsgsCOnPwZiEe07xj6+ACdGqgK
EAWLted0R1tEBE/CtpUEN/c=
=YagS
> Operating under the fairly certain assumption that (2*PI) radians = 360
> degrees, I simply replace pi with 180 degrees in the classic geometric
> functions. Thus:
>
I see what you're driving at, but the fact that 2*pi radians = 360 degrees
still
does not change the value of pi (thankfully)!
> To satisfy your question, however, my value of pi, stored permanently in
> my brain to six significant digits since Mr. Chatfield's calc class in
> high school: 3.14159 ;)
>
I have 3.141592653
C:\>python
Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import pi
>>> pi
3.1415926535897931
>>>
Cheers.
...
>
> Well, now that I have conquered elementry trig, I am now going to try
> for simple python and figure out how to add the contents of a tuple to
> the contents of another tuple...
>
Try '+'
>>> a
(1, 2)
>>> b
(3, 4)
>>> a+b
(1, 2, 3, 4)
>>>
sorry, I wasn't very clear, in the above example, the result I am
looking for is
>>>a=(1,2)
>>>b=(2,3)
>>>a+b
(3,5)
if that makes sense, I don't want to append, I want to add.
>
>
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81YW4d90bcYOAWPYRAoTvAKCwwIqQts+K+Bi3JWZWZ1UIz87pYQCgxuwd
wicTymWLn2xqKFnoEZkRXSg=
=NVVK
> sorry, I wasn't very clear, in the above example, the result I am
> looking for is
>
>>>>a=(1,2)
>>>>b=(2,3)
>>>>a+b
> (3,5)
>
>
> if that makes sense, I don't want to append, I want to add.
>
Use Numeric for that (unless you want to write your own code, of course). Its
arrays work in this way, which is different to that of python's normal
sequence types.
cheers,
f.
>>> [ x + y for x, y in zip( a, b ) ]
[4, 6]
>>>
this would be the numeric python module?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81ZdCd90bcYOAWPYRAsghAJ9Mj6amq90GuRI0SKMECCZIpoC2PwCdED3F
iCnr6xUE4/NuBU6AkpmFL1o=
=NUYB
>> Use Numeric for that (unless you want to write your own code, of course).
>> Its arrays work in this way, which is different to that of python's normal
>> sequence types.
>>
>> cheers,
>>
>
> this would be the numeric python module?
>
Yes: http://www.pfdubois.com/numpy/
Cheers,
f.
Then, you want elementwise operations. Take a look at
matfunc.py at http://users.rcn.com/python/download/python.htm
>>> from matfunc import Vec
>>> Vec([1,2]) + Vec([2,3])
[3, 5]
Raymond Hettinger
Well, you can learn about Python's OO nature by writing class to handle
this:
class vector:
def __init__(self, x=[]): # vector([...])
self.array = x[:]
self.n = len(x)
def __repr__(self):
return `self.array`
def __add__(self, other):
for a, b in map(None, self.array, other.array):
out.append(a + b)
return vector(out)
>>> a = vector([1,2])
>>> b = vector([2,3])
>>> a+b
[3, 5]
--
William Park, Open Geometry Consulting, <openge...@yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin
You can make both these tasks a litte easier
using the following handy function:
def curse_babylonian_astronomers(d):
import math
return d * math.pi / 180.0
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
No, pi is thankfully constant. I was just taking a misunderstanding to
its illogical conclusion.
>> To satisfy your question, however, my value of pi, stored permanently
>> in my brain to six significant digits since Mr. Chatfield's calc
>> class in high school: 3.14159 ;)
>
> I have 3.141592653
Nice. Should be more than enough, considering many professors accept
(22/3) as a reasonable value (~3.142857...)
> C:\>python
> Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from math import pi
>>>> pi
> 3.1415926535897931
>>>>
Anyway, that's what we need! A Python (or, maybe, Ruby) interpreter
embedded in our brain. Gods, wouldn't that make bill-paying easier!
Tim Hammerquist
--
Randal can write one-liners again. Everyone is happy, and peace spreads
over the whole Earth.
-- Larry Wall in <1997051019...@wall.org>
> Nice. Should be more than enough, considering many professors accept
> (22/3) as a reasonable value (~3.142857...)
>
you mean 22/7:
In [1]: 22/7.
Out[1]: 3.1428571428571428
In [2]: pi
Out[2]: 3.1415926535897931
In [3]: 100*(__-_)/_
Out[3]: 0.040249943477070081
It's actually pretty good, .04% error is enough for most day to day things.
Cheers,
f.
Of course. Dammit.
"Coffee..... Coffee NOW!"
-- Droz, "PCU"
Tim Hammerquist
--
In 1968 it took the computing power of 2 C-64's to fly a rocket to the moon.
Now, in 1998 it takes the Power of a Pentium 200 to run Microsoft Windows 98.
Something must have gone wrong.
On Mon, 06 May 2002 17:36:46 +1200,
Greg Ewing <gr...@cosc.canterbury.ac.nz> wrote:
> Robert George Mayer wrote:
>>
>> I find that it help to curse the Babylonian astronomers while
>> putting all the conversions in place.
>
> You can make both these tasks a litte easier
> using the following handy function:
>
> def curse_babylonian_astronomers(d):
> import math
> return d * math.pi / 180.0
>
argh!
I tried that, and Marduk smashed my computer with an Axe.... bad thing,
very bad thing....
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81s5pd90bcYOAWPYRAnMuAKDWK9VdZxBm8YXqmUWohx2h5FSCswCfdwjI
BIDbbHQyp1E8Chg5JmdYHhw=
=06/B
On 6 May 2002 05:05:38 GMT,
William Park <openge...@NOSPAM.yahoo.ca> wrote:
> Jim Richardson <war...@eskimo.com> wrote:
>> sorry, I wasn't very clear, in the above example, the result I am
>> looking for is
>>
>>>>>a=(1,2)
>>>>>b=(2,3)
>>>>>a+b
>> (3,5)
>
> Well, you can learn about Python's OO nature by writing class to handle
> this:
>
> class vector:
> def __init__(self, x=[]): # vector([...])
> self.array = x[:]
> self.n = len(x)
>
> def __repr__(self):
> return `self.array`
>
> def __add__(self, other):
> for a, b in map(None, self.array, other.array):
> out.append(a + b)
> return vector(out)
>
>>>> a = vector([1,2])
>>>> b = vector([2,3])
>>>> a+b
> [3, 5]
>
Thanks. Actually, I am a little intimidated by the whole OO and class
thing. I still don't "grok" the whole OO thing.
I don't understand what the (self,...) part of the init is. I *think* I
know what __init__ is for, to set up the things you need to use the
functions (methods?) within the class, but what's with self all over the
place?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE81s4yd90bcYOAWPYRAkBWAJ41AnR4O7V84xaT+J6U0p1TyNtowACeOeMo
Zs0TJHmg894Qa353mtLwSbw=
=un2O
out = [] <-- missed when I cut/paste... sorry.
>> for a, b in map(None, self.array, other.array):
>> out.append(a + b)
>> return vector(out)
>>
>>>>> a = vector([1,2])
>>>>> b = vector([2,3])
>>>>> a+b
>> [3, 5]
>>
>
>
> Thanks. Actually, I am a little intimidated by the whole OO and class
> thing. I still don't "grok" the whole OO thing.
>
> I don't understand what the (self,...) part of the init is. I *think* I
> know what __init__ is for, to set up the things you need to use the
> functions (methods?) within the class, but what's with self all over the
> place?
The function is called with parameter 'self' replaced by the object itself.
You can use any function parameter names, but 'self' is used by convention.
There is a patch for adding degree/radian conversions.
See http://www/python.org/sf/552452
Raymond Hettinger
Sorry to sound critical, but I doubt this will make it in (and I hope it
doesn't). Reason: bloat. Yes, it's only two functions, but still, bloat is
bloat. Plus, if you really need those conversions, it's less typing and more
efficient (no function call) to simply use a multiplicative constant:
In [7]: to_rad = pi/180
In [8]: to_deg = 1/to_rad
In [9]: sin pi/4
------> sin (pi/4)
Out[9]: 0.70710678118654746
In [10]: sin 45*to_rad
-------> sin (45*to_rad)
Out[10]: 0.70710678118654746
In [11]: (pi/4)*to_deg
Out[11]: 45.0
I realize you have good intentions, but I truly don't think that in this case
the benefits outweigh the cost. OTOH, one could add a comment in the
docstrings to the effect of 'trig functions expect arguments in radians',
since it does seem to cause confusion among newbies.
Cheers,
f.
Let's make that pi/180.0 so it works before the division unification takes
place, shall we?
>
> In [8]: to_deg = 1/to_rad
>
> In [9]: sin pi/4
> ------> sin (pi/4)
Similarly this should be pi/4.0
> Out[9]: 0.70710678118654746
>
> In [10]: sin 45*to_rad
> -------> sin (45*to_rad)
> Out[10]: 0.70710678118654746
>
> In [11]: (pi/4)*to_deg
> Out[11]: 45.0
>
> I realize you have good intentions, but I truly don't think that in this
case
> the benefits outweigh the cost. OTOH, one could add a comment in the
> docstrings to the effect of 'trig functions expect arguments in radians',
> since it does seem to cause confusion among newbies.
>
But these would be maths newbies as well as Python newbies. The comment is a
good idea.
regards
Steve
--
Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/
> Let's make that pi/180.0 so it works before the division unification takes
> place, shall we?
>>
>> In [8]: to_deg = 1/to_rad
>>
>> In [9]: sin pi/4
>> ------> sin (pi/4)
>
> Similarly this should be pi/4.0
>
It doesn't matter, math.pi is a float (unless Guido decides to use the
Congress version of pi==3 ;)
Cheers,
f.
>> I realize you have good intentions, but I truly don't think that in this
> case
>> the benefits outweigh the cost. OTOH, one could add a comment in the
>> docstrings to the effect of 'trig functions expect arguments in radians',
>> since it does seem to cause confusion among newbies.
>>
> But these would be maths newbies as well as Python newbies. The comment is a
> good idea.
Indeed I meant math newbies rather than Python newbies. Thanks for the
clarification, that's what I had in mind but wasn't explicit enough. This can
actually bite a very experienced programmer who simply isn't too familiar
with math details.
Cheers,
f.
On 6 May 2002 20:19:32 GMT,
OK, I think... I'll have to cogitate on this. Thanks for the help.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE8119md90bcYOAWPYRAlOAAJ98AcmzTzzgLajOzjjAbIa5KCXMRQCfaRPn
s7e6Ne1P0u1UhbGD29nSEe8=
=mKel
Well, it was a lightbulb going off in my head when I finally figured out
*why* the numbers my code was giving me were so wrong. Doh! after I
thought about it, it made perfect sense, but before I had thought about
it :)....
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE811/kd90bcYOAWPYRAmF6AKCya2mJ44k0UCixEg5SCl7KCjPevACeJJ5C
0DF1Qa/PoRvFn2L1wa9SihI=
=dCLr
This may help ...
http://www.ibiblio.org/obp/thinkCSpy/
Tim Delaney
Cool link, thank you!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE813Qwd90bcYOAWPYRAtFMAJwIYnIFF69nibghoi7v+8TVPVjddQCgiy/q
3L3zA8dSH5/K33BPNOowlwo=
=wKeG
Well if it's just a one-off you can use a simple list comprehension
[a+b for a,b in zip(a,b)]
[3,5]
if you specifically need a tuple then wrapping the above in tuple()
will do the conversion.
However if this is likely to be a common task (as I suspect), then you
are better off using Numeric as suggested, or (less likely) rolling
your own class.
Andrae Muys
Try the "Instant Python" page. Find it on Google or follow links from
python.org.
Huaiyu
On 7 May 2002 17:46:39 -0700,
I am going to look into numeric thanks, and also zip, I don't recal this
from 1.5? is it new with 2.0?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE82L1Ud90bcYOAWPYRAuLwAJ44s0WfeNqPeio5z/vjwj+u1NoHrwCgijpn
Kip+FQUnQoHEli8vERJ6zjw=
=YhR/
Thanks
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE82L1jd90bcYOAWPYRAs8nAJ9DAGJCpeYDSoK9l97o/e52jdpdVwCfdpGv
ImEBAtbixBb7N6JyVCpMccI=
=wpdc