From: D-Man <ds...@ri...> - 2001-04-05 14:48:01
|
On Thu, Apr 05, 2001 at 05:41:05PM -0400, cindy wrote: | In the jython doc , under Calling Methods in your Superclass", I quote | "In Python, if I want to call the foo method in my superclass, I use the | following | | SuperClass.foo(self) | | This works with the majority of methods, but protected methods can not | be called from subclasses in this way. Instead you have to use the | "self.super_foo()" call style." I beleave the latter syntax is telling me | I have to use inheritance. Am I wrong? Both syntaxes use inheritance. | Wayne | | P.S. I have several books in which I'm using to learn java. What I thought | I do to learn jython was rewite all the examples in the book in jython. This | is how my problen came about. My the way the book is, "Beiginning Java" | by Ivor Horton The problem you are seeing here comes from mixing Python and Java semantics and syntax together without first understanding either of them. In Python, all functions are "public", and to call an overridden method in a superclass you use the SuperClass.function( self ) syntax ('SuperClass' isn't a keyword). In Java it is simply super.function() ('super' is a keyword). Also, java has "public" "protected" and "private" attributes which complicates the Python<->Java bridging. I would highly recommend that you learn one language first, then the other language, then put them together. The combined semantics make much more sense when you understand each language's semantics. IMO Python is much simpler and easier to learn (while being more powerful at a high level) than Java, so I would recommend learning python first. The tutor list is great at helping new people learn the basics of programming in a python environment (tu...@py...). Once you know python or java fairly well the hoops jython jumps through to provide as simple and clean as possible bridge between the two makes much more sense and is easier to grasp. -D |