= @property = {{{#!highlight python class Orchestration(object): def __init__(self): self._choreo1 = None self._choreo2 = None @property def choreo1(self): if self._choreo1 is None: print 'Connecting to Choreo1' self._choreo1 = Choreo1() return self._choreo1 @choreo1.setter def choreo1(self, value): msg = 'Setting to %s does not make sense in this example' % value raise AttributeError(msg) @choreo1.deleter def choreo1(self): raise AttributeError('Deleting neither') @property def choreo2(self): if self._choreo2 is None: print 'Connecting to Choreo2' self._choreo2 = Choreo2() return self._choreo2 def bla(self): self.choreo1.foo() self.choreo1.bar() self.choreo2.gurki() def blubb(self): self.choreo2.gurki() class Choreo1(object): def foo(self): print 'Doing foo' def bar(self): print 'Doing bar' class Choreo2(object): def gurki(self): print 'Doing gurki' def main(): o = Orchestration() print 'Do bla' o.bla() print 'Done with bla' print o = Orchestration() print 'Do blubb' o.blubb() print 'Done with blubb' if __name__ == '__main__': main() }}}