John M. Gabriele wrote:
I know that Python doesn't do method overloading like
C++ and Java do, but how am I supposed to do something
like this:
This was just discussed. See
http://tinyurl.com/6zo3g
Kent
--------------------- incorrect ------------------------
#!/usr/bin/python
class Point3d:
pass
class Vector3d:
"""A vector in three-dimensional cartesian space."""
def __init__( self ):
"""Create a Vector3d with some reasonable default value."""
x, y, z = 0.0, 0.0, 0.0
def __init__( self, x_from, y_from, z_from,
x_to, y_to, z_to ):
"""Create a Vector3d from x-y-z coords."""
# ...
pass
def __init__( self, point_from, point_to ):
"""Create a Vector3d from two Point3d objects."""
# ...
pass
def __init__( self, same_as_this_vec ):
"""Create a Vector3d from a copy of another one."""
# ...
pass
p = Point3d()
p2 = Point3d()
# v = Vector3d( p2, p ) -- Nope. Only the last __init__() counts.
---------------------- /incorrect -------------------------------
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list