[Tutor] Another Class question.

Lance E Sloan lsloan@umich.edu
Thu, 15 Aug 2002 12:47:15 -0400


--On Thursday, August 15, 2002 7:58 AM -0500 SA <sarmstrong13@mac.com> 
wrote:
> If you have two classes, I'll try to keep it simple but I'm sure this can
> be scaled upwards, and you create an instance for each, how would you
> pass data from on instance to the next?
>
> Is this done by assignment?
>
> For example(really general):
>
> class 1: #The first class
>     ...
> class 2: #The second class
>     ...
>
> x = 1() #create instance of first class
> y = 2() #create instance of second class
>
> x(..) #do some work on some data through this instance
> y(x) #pass result from first instance to second for more manipulation?

Calling the methods would probably look like:

x.process(data)
y.process(x.get_processed_data())

You would have to define the get_processed_data method of class 1.  Or 
maybe you don't want to use a method.  You could just access the instance 
variable of x that's holding the data.

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Python & Perl CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"