using names before they're defined

Larry Bates larry.bates at websafe.com
Thu Jul 20 17:03:01 EDT 2006


I don't know if you saw my earlier post but something like
this has worked for me.

What about something like:

supply = supply()
compressor = compressor(supply)
combuster1= combuster(compressor)
combuster2= combuster(compressor)
compressor.append(combuster1)
compressor.append(combuster2)

or perhaps

compressor.extend([combuster1, combuster2])


turbine = turbine(combuster)
combuster.append(turbine)


If you implement .append and .extend methods
on your classes they will allow you to append single
downstream objects or extend with a list of them.
Just keep a list self.downstream and append/extend
it.  IMHO it makes what is going on intuitively obvious.

-Larry Bates

davehowey at f2s.com wrote:
> Bruno,
> 
> Thanks. An issue is that I need to be able to link multiple objects to
> a single object etc.
> Say for example using the previous wording, I might have compressor -
> multiple combustors - turbine
> 
> this complicates things slightly.
> 
> my current thought is to do a two stage initialisation
> 
> 1. create the objects
> compressor = compressor()
> combuster1 = combuster()
> combuster2 = combuster()
> 
> etc
> 
> 2. link them
> compressor.link(downstream = [combuster1, combuster2])
> combuster1.link(upstream = compressor)
> etc.
> 
> hmmmm I need to give it some more though, particularly how I solve all
> the linked objects (which is the point)
> 
> Dave
> 



More information about the Python-list mailing list