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:
>
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:
This was discussed only days ago:
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/41a6c0e1e260cd72/fc1c924746532316?q=multiple+constructors+python&_done=%2Fgroups%3Fq%3Dmultiple+constructors+python%26&_doneTitle=Back+to+Search&&d#fc1c924746532316
-Don
John M. Gabriele wrot
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 prefer
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."""