You can call "self" on an abstract object, you just can't instantiate an abstract object. An abstract object has all the state and behaviour of a normal, concrete object it just can't live on it's own. It needs to be subclassed and made abstract. For a good example of this, check out the java.io.* packages, in particular, either the Reader/Writer or InputStream/OutputStream classes and their subclasses. Look at FileReader and you'll notice it is an implementation of the abstract Reader class, all FileReader provides to Reader is how to get the initial data, in this case a File.
Python really doesn't have the notion of an abstract class, in general an abstract class or interface is implemented by defining a bunch of methods which raise Exceptions.
So in your case, you can't instantiate a Component, but you can get subclasses of Component and then call methods on them.
hope this helps,
[mailto:email@example.com]On Behalf Of cindy
Sent: Wednesday, April 04, 2001 3:48 AM
Subject: Re: [Jython-users] A big problem for me!
> class Foo :
> def func( self ) :
> print "func was called"
> def runme( self ) :
> func() # this won't work as you've seen in your code
> def runme2( self ) :
> self.func() # this will work as expected
This I undertstand, but I don't see how "self" can be used on a
class that is inherited and that is abstract, such as Component.
When I do "self.enableEvents(java.awt.event.WindowEvent.WINDOW_EVENT_MASK)"
I get an AttribueError on enableEvents, which I would expect.
Jython-users mailing list