how do I pass values between classes?

jim-on-linux inq1ltd at verizon.net
Mon Nov 6 17:07:30 CET 2006


Kath,
You can use this class to pass values around 
without concern for conflicts since it has no 
values of its own.


class Kvariable:
      def setVariable(self, variable):
          self.output = variable

      def showVariable(self):
          print self.output     
      
x = Kvariable()
y = Kvariable()

x.setVariable("James_01")
y.setVariable("Kath_01")

x.showVariable()
y.showVariable()


x.setVariable('3.14159')
y.setVariable("python.org")

x.showVariable()
y.showVariable()

jim-on-linux

http://www.inqvista.com














On Monday 06 November 2006 02:00, kath wrote:
> hi, Larry Bates .... thanks for the reply...
>
> > You might consider doing it the same way wx
> > passes things around. When you instantiate
> > the subclass pass the parent class' instance
> > as first argument to __init__ method.
>
> Yes thats absolutely right..
>
> > That way the subclass can
> > easily pass values back to the parent by
> > using that pointer.
>
> Could you please explain me this.. more
> clearly. I think it is much close to the
> solution.
>
>
> Thank you.
> regards, sudhir



More information about the Python-list mailing list