Class, object question.
Jeffrey Maitland
maitj at vianet.ca
Tue Apr 5 10:04:08 EDT 2005
Hello folks,
The question I am having is something like this.
# ignore the precursing .. I am using them for easy message formatting
from point import *
Class vector(point):
..........def __init___(self, point1, point2):
.......self.i = point2.get_x() - point1.get_x()
.......self.j = point2.get_y() - point1.get_y()
.......self.k = point2.get_z() - point1.get_z()
# methods of vector. Defined here.
What I am wondering is if I have a 2nd init or something similar to
create a vector. Such as what follows and if I can how do I go about
implementing it?
Class vector(point):
..........def __init___(self, point1, point2):
.......self.i = point2.get_x() - point1.get_x()
.......self.j = point2.get_y() - point1.get_y()
.......self.k = point2.get_z() - point1.get_z()
.
..........def __init___(self, i, j, k):
.......self.i = i
.......self.j = j
.......self.k = k
That way I can define a vector either using 2 points or if I have the
vector data itself?
Thanks in advance
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050405/b7b6fa19/attachment.html>
More information about the Python-list
mailing list