function overloading

David Mertz mertz at gnosis.cx
Sat May 24 13:13:06 EDT 2003


|Mirko Koenig wrote:
|> I want to have 3 functions:
|> def setPos( x, y ):
|> def setPos( pos ):
|> def setPos( object ):

Alex Martelli <aleaxit at yahoo.com> wrote previously:
|You cannot have three different objects (for example, three different
|functions) corresponding to the same name in the same scope.  One name,
|one scope, one object.

Readers of this thread might be interested in my article and library for
multiple dispatch in Python:

    http://www-106.ibm.com/developerworks/linux/library/l-pydisp.html

While a given name is still only defined once, it is possible to control
the code called based on the type and number of its arguments.

Take it or leave it... it may not be the best approach to Koenig's
concern.  But maybe something to consider.

--
    _/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: Postmodern Enterprises _/_/_/
   _/_/    ~~~~~~~~~~~~~~~~~~~~[mertz at gnosis.cx]~~~~~~~~~~~~~~~~~~~~~  _/_/
  _/_/  The opinions expressed here must be those of my employer...   _/_/
 _/_/_/_/_/_/_/_/_/_/ Surely you don't think that *I* believe them!  _/_/






More information about the Python-list mailing list