degrees and radians.

Jim Richardson warlock at eskimo.com
Tue May 7 01:00:22 EDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6 May 2002 20:19:32 GMT,
 William Park <opengeometry at NOSPAM.yahoo.ca> wrote:
> Jim Richardson <warlock at eskimo.com> wrote:
>>>     class vector:
>>>       def __init__(self, x=[]):               # vector([...])
>>>           self.array = x[:]
>>>           self.n = len(x)
>>> 
>>>       def __repr__(self):
>>>           return `self.array`
>>> 
>>>       def __add__(self, other):
> 
> 	     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.
> 

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
-----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. 



More information about the Python-list mailing list