Re: Do I need self and other?

2008-06-30 Thread David C. Ullrich
In article [EMAIL PROTECTED], Kurda Yon [EMAIL PROTECTED] wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)):

Re: Do I need self and other?

2008-06-28 Thread Peter Pearson
On Fri, 27 Jun 2008 20:19:00 -0400, Nick Dumas [EMAIL PROTECTED] wrote: [snip] Example: class Foo(): self.x = 5 Have you tried what you're posting? Python 2.4.3 (#2, Oct 6 2006, 07:52:30) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type help, copyright, credits or license for more

Re: Do I need self and other?

2008-06-28 Thread Gabriel Rossetti
Kurda Yon wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)): data.append(self.data[j] + other.data[j]) return Vector(data) In

Re: Do I need self and other?

2008-06-28 Thread Nick Dumas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Peter Pearson wrote: On Fri, 27 Jun 2008 20:19:00 -0400, Nick Dumas [EMAIL PROTECTED] wrote: [snip] Example: class Foo(): self.x = 5 Have you tried what you're posting? Python 2.4.3 (#2, Oct 6 2006, 07:52:30) [GCC 4.0.3 (Ubuntu

Re: Do I need self and other?

2008-06-27 Thread Hans Nowak
Kurda Yon wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)): data.append(self.data[j] + other.data[j]) return Vector(data) In

Re: Do I need self and other?

2008-06-27 Thread Kurda Yon
On Jun 27, 6:32 pm, Hans Nowak [EMAIL PROTECTED] wrote: Kurda Yon wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)):

Re: Do I need self and other?

2008-06-27 Thread Terry Reedy
Kurda Yon wrote: OK, I see. In the given example self is just a name which can be replace by whichever (valid) name. Is that always like that? I mean, does slef have a special meaning in some cases or it is always just a name like any other? Yes. A method is a function bound to a class or

Re: Do I need self and other?

2008-06-27 Thread Robert Kern
Terry Reedy wrote: Kurda Yon wrote: OK, I see. In the given example self is just a name which can be replace by whichever (valid) name. Is that always like that? I mean, does slef have a special meaning in some cases or it is always just a name like any other? Yes. A method is a function

Re: Do I need self and other?

2008-06-27 Thread Luis Zarrabeitia
On Friday 27 June 2008 06:41:22 pm Kurda Yon wrote: OK, I see. In the given example self is just a name which can be replace by whichever (valid) name. Is that always like that? I mean, does slef have a special meaning in some cases or it is always just a name like any other? I am asking that

Re: Do I need self and other?

2008-06-27 Thread Nick Dumas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Kurda Yon wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)):

Re: Do I need self and other?

2008-06-27 Thread Roy Smith
In article [EMAIL PROTECTED], Kurda Yon [EMAIL PROTECTED] wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)):

Re: Do I need self and other?

2008-06-27 Thread Roy Smith
In article [EMAIL PROTECTED], Kurda Yon [EMAIL PROTECTED] wrote: OK, I see. In the given example self is just a name which can be replace by whichever (valid) name. Is that always like that? I mean, does [self] have a special meaning in some cases or it is always just a name like any other?

Re: Do I need self and other?

2008-06-27 Thread Maric Michaud
Le Saturday 28 June 2008 00:17:33 Kurda Yon, vous avez écrit : class Vector:   def __add__(self, other):     data = []     for j in range(len(self.data)):       data.append(self.data[j] + other.data[j])     return Vector(data) In this example one uses self and other. Does one really need