__init__ question
Adrian Eyre
a.eyre at optichrome.com
Tue Aug 10 08:52:48 EDT 1999
> > a = Vector() # x=0 y=0 z=0
> > a = Vector( 1) # x=1 y=1 z=1
> > a = Vector( 1, 2, 3) # x=1 y=2 z=3
> def __init__(self, x=0, y=0, z=0):
How about:
>>> class Vector:
... def __init__(self, *args):
... print args
...
>>> v=Vector()
()
>>> v=Vector(1)
(1,)
>>> v=Vector(1,2)
(1, 2)
...etc.
You can then parse the args in the constructor.
--------------------------------------------
Adrian Eyre <mailto:a.eyre at optichrome.com>
Optichrome Computer Solutions Ltd
Maybury Road, Woking, Surrey, GU21 5HX, UK
Tel: +44 1483 740 233 Fax: +44 1483 760 644
http://www.optichrome.com
--------------------------------------------
More information about the Python-list
mailing list