def code_gen(blocks):
 decl = ''
 head = ''
 tail = ''
 for block in blocks:
  decl += block.declare
  head = (head + ('\n{\n%s' % block.behavior))
  tail = (('%s\n}\n' % block.cleanup) + tail)
 return ((decl + head) + tail)

def code_gen ( blocks ) : decl = '' head = '' tail = '' for block in blocks : decl += block . declare head = ( head + ( '\n{\n%s' % block . behavior ) ) tail = ( ( '%s\n}\n' % block . cleanup ) + tail ) return ( ( decl + head ) + tail )
from a list of l{codeblock} instances .