function overloading
Jere Kahanpaa
kahanpaa at gstar.astro.helsinki.fi
Thu Jul 3 02:33:38 EDT 2003
Hi.
Mirko Koenig <koenig at v-i-t.de> wrote:
> I serached around the web and some tutorials but i can't finds any
> documentation about function overloading in python.
> I want to have 3 functions:
> def setPos( x, y ):
> def setPos( pos ):
> def setPos( object ):
> ( pos and object are classes i wrote )
The normal Pythonic way is probably as follows:
def setPos(position):
"""
Set Position.
The 'position' argument should be one of
* a tuple of coordinates (x,y)
* a instance of class Pos
* a instance of class Object
"""
if type(positions) is types.TupleType or type(positions) is types.ListType:
x,y = positions
...
else if:
... identify object type and process
Jere
--
It's hard to think outside the box when you ARE the box.
- unknown, alt.religion.kibology
More information about the Python-list
mailing list