overloading ( was Different methods with same name but different signature? ) - overloadinginpython.tar.gz (0/1)

Kevin Dahlhausen morse at harborcom.net
Thu Apr 15 10:07:52 EDT 1999


Here's some code by Bjorn Pettersen that implements a
scheme for overloaded member functions.   I've not messed
RTTI in user types, but I think you might need to overload whatever
handles the type info for a user class in each of your user classes.

Bjorn's code uses the types of all parameters passed to a function
as key into a dictionary containing the correct function for various 
types of input paramters.  It works very well.


frederic pinel <fpinel at fedex.com> wrote:
>Hello,
>
>While trying to implement the visitor pattern in Python, I ran into the
>following problem:
>
>My class needs to have 2 (or more) different methods, but with the same
>name, the difference being the signature (an object in my case),
>unfortunately Pyhton interprets this as an overidding, and only
>considers the last method defined.
>C++ being able to switch to the right method, based on the signature, I
>thought Python would.






More information about the Python-list mailing list