using names before they're defined

davehowey at f2s.com davehowey at f2s.com
Wed Jul 19 11:30:36 EDT 2006


I have a problem. I'm writing a simulation program with a number of
mechanical components represented as objects. When I create instances
of objects, I need to reference (link) each object to the objects
upstream and downstream of it, i.e.

supply = supply()
compressor = compressor(downstream=combustor, upstream=supply)
combuster = combuster(downstream=turbine, upstream=compressor)
etc.

the problem with this is that I reference 'combustor' before is it
created. If I swap the 2nd and 3rd lines I get the same problem
(compressor is referenced before creation).


aargh!!! any ideas on getting around this?

Dave




More information about the Python-list mailing list