jython/java inheritance question?

Alan Kennedy alanmk at hotmail.com
Wed Oct 29 07:10:22 EST 2003


Matt Newcomb wrote:
> I've got a jython script that contains a class that extends the
> ChannelIteratorAlgorithm class ( are you having fun yet? ) and it's
> got a processSampledChannelGroup method that looks like this:
> 
> class testalg(ChannelIteratorAlgorithm):
>     def processSampledChannelGroup(self, inGroups, outGroups):
>         if (self.samplesToPass!=0):
>             print "samples left: %d" % self.samplesToPass
>             ChannelIteratorAlgorithm.processSampledChannelGroup(self,
> inGroups,
> outGroups)
> 
> However, each time I try to run this script I get this exception:
> 
> 2003-10-29 05:26:29 ERROR:: spigot_1.handleData() encountered a fatal
> Exception:Traceback (innermost last):
>   File "<string>", line 187, in processSampledChannelGroup
> AttributeError: class
> 'gov.nasa.gsfc.irc.algorithms.ChannelIteratorAlgorithm' has no
> attribute 'processSampledChannelGroup'
> 
> What?!?!?!  Why an attribute and not a method?  And why, given that
> yes there is an implementation of processSampledChannelGroup in the
> ChannelIteratorAlgorithm class and yes it really looks like:
> 
>         protected void processSampledChannelGroup
>                 (Object[] inputChannelDataBuffersForGroup,
>                 Object[]  outputChannelDataBuffersForGroup)
> 
> would there be an issue?

Yes: The method is protected, meaning that you cannot call it directly
as you are trying to above. See the following jython doc page for more
information

http://www.jython.org/docs/subclassing.html

This might work

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

class testalg(ChannelIteratorAlgorithm):

  def processSampledChannelGroup(self, inGroups, outGroups):

    if (self.samplesToPass!=0):
      print "samples left: %d" % self.samplesToPass
      self.super__processSampledChannelGroup(inGroups, outGroups)

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

HTH,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list