Function parameter type safety?

Michele Simionato michele.simionato at gmail.com
Fri Jul 13 11:06:08 EDT 2007


On Jul 13, 4:53 pm, Robert Dailey <rcdai... at gmail.com> wrote:
> Good replies.
>
> I'm in the process of learning Python. I'm a native C++ programmer, so
> you can see how the question relates. There's a lot of cool things C++
> allowed you to do with type-checking, such as function overloading.

This is an area of hot debate in Python and things are changing. You
may want
to have a look at http://www.python.org/dev/peps/pep-3119 about
interfaces,
and to http://www.python.org/dev/peps/pep-3124 about overloading and
generic functions. Both PEPs are for Python 3000, but their existence
should be an indication that people are not happy with the current
situation
in Python. You can something better than overloading already, with
P.J. Eby
modules simplegeneric and/or RuleDispatch, but I would say that they
are not
commonly used. So the right thing to do for now is to follow the good
advices you received, but keep in mind that there will be alternatives
in
the near future (such as interface checking/function overload).

      Michele Simionato




More information about the Python-list mailing list