Like overloading __init__(), but how?

2005-02-23 Thread John M. Gabriele
I know that Python doesn't do method overloading like C++ and Java do, but how am I supposed to do something like this: - incorrect #!/usr/bin/python class Point3d: pass class Vector3d: A vector in three-dimensional cartesian space.

Re: Like overloading __init__(), but how?

2005-02-23 Thread Steven Bethard
John M. Gabriele wrote: class Vector3d: def __init__(self): ... def __init__(self, x_from, y_from, z_from, x_to, y_to, z_to): ... def __init__(self, point_from, point_to): ... def __init__(self, same_as_this_vec): ... My

Re: Like overloading __init__(), but how?

2005-02-23 Thread John M. Gabriele
On Wed, 23 Feb 2005 21:32:52 -0700, Steven Bethard wrote: [snip] Another possibility is to play around with *args: class Vector3d(object): def __init__(self, *args): if not args: # constructor with no arguments elif len(args) == 6: #