36 lines
1.3 KiB
Plaintext
36 lines
1.3 KiB
Plaintext
From: morse at harborcom.net (Kevin Dahlhausen)
|
|
Date: Thu, 15 Apr 1999 14:07:52 GMT
|
|
Subject: overloading ( was Different methods with same name but different signature? ) - overloadinginpython.tar.gz (0/1)
|
|
References: <3716909C.D8D1B372@fedex.com>
|
|
Message-ID: <3715f152.73653197@news.oh.verio.com>
|
|
X-UID: 643
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|