On 09/07/2014 20:17, Danny Yoo wrote:
My error was simply that I inadvertently used the same name for a method
(function) in the derived class that I had already used in the parent class.
The result was then a very obscure error because the wrong calculation was
performed and later on an array was empty.
Fortunately, thanks to you very generous tutors I have learned to read the
error trace very carefully indeed.
Ah, yes, that one. It's happened to me too.
It's one of the reasons why inheritance makes me nervous sometimes.
It's a problem that's fairly language-independent.
(If you'd like to know the details, the example that I was involved in
is described in the comments on:
https://github.com/bootstrapworld/js-numbers/pull/5. Essentially, we
subclassed some base class, and wrote a method called BigNumber.exp()
to do exponentiation. Unfortunately, we didn't realize that our
superclass already had defined an exp() method. It ended up showing
up as a very strange, obscure error. Same class of problem.)
Side note, Python does have a hack called "name mangling" that can be
used to try to avoid this problem:
https://docs.python.org/2/tutorial/classes.html#private-variables-and-class-local-references
Good luck!
Thanks for the reply.
I had read the second reference that you gave some time ago, but of
course I had forgotten about it.
I shall try and make use of it now.
Thanks for the help.
--
Sydney Shall
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor