36 lines
1.0 KiB
Plaintext
36 lines
1.0 KiB
Plaintext
From: fpinel at fedex.com (frederic pinel)
|
|
Date: Fri, 16 Apr 1999 03:21:32 +0200
|
|
Subject: Different methods with same name but different signature?
|
|
Message-ID: <3716909C.D8D1B372@fedex.com>
|
|
X-UID: 978
|
|
|
|
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.
|
|
|
|
Being new to Python, is this a limitation or am I missing something?
|
|
(Python being great I suspect -and hope- it's my ignorance!)
|
|
|
|
Any help would be great!
|
|
|
|
PS: as a workaround, I tried:
|
|
- using a single method, but checking isinstance() of the object passed
|
|
to switch to the right code,
|
|
- using different names for the methods,
|
|
which both work.
|
|
|
|
regards,
|
|
frederic
|
|
|
|
|
|
|
|
|