other python ideas

Richard Brodie R.Brodie at rl.ac.uk
Tue May 23 15:36:07 CEST 2000

"Thomas Thiele" <thiele at muc.das-werk.de> wrote in message news:392A7F84.A3D5F34A at muc.das-werk.de...
> function overloading is a goog idea. It's really the only thing I miss in
> python.
> But then it must be possible to check different data-types (like in C++).
> def foo(   (int)a  ):
>     print a, "is a int"
> def foo(   (float)a  ):
>     print a, " is a float"

It's not so hard to write a dispatch function if that's what you really want:

from types import *

def overloaded(t):
    dispatch = { IntType: intFunc, FloatType: floatFunc}
    if dispatch.has_key(type(t)) :
    else :

More information about the Python-list mailing list