[Tutor] passing arguments via an instance of a class

Kent Johnson kent37 at tds.net
Wed Apr 4 14:34:10 CEST 2007


Alan Gauld wrote:
> "Kent Johnson" <kent37 at tds.net> wrote
> 
>>>> #these are the points I want to be plotted when I push this button
>>>>        xpoints=[2,4,6]
>>>>        ypoints=[10,20,30]
>>>>        self.weightplot = PlotPanel(self.notebook1,xpoints,ypoints)
>>> But this needs to use self to access the member values:
>>>
>>>         self.weightplot =
>>> PlotPanel(self.notebook1,self.xpoints,self.ypoints)
>> A minor correction to an otherwise excellent explanation - xpoints 
>> and
>> ypoints are not member variables here - they are ordinary local
>> variables - so 'self' is not needed.
> 
> I was assuming that the two locals were temporary stop gaps and
> that the actual requirement was for the original xpoints to be used.
> If the locals are intentional then yes indeed, the self is not needed
> in this case.

Ah. I was assuming that in the real code this function would pull the desired points from the GUI somewhere, since the function is an event handler and not part of the PlotPanel class. 

Kent


More information about the Tutor mailing list