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)):
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
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
-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
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
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)):
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
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
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
-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)):
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)):
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?
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
13 matches
Mail list logo