def pagebreak(type='page', orient='portrait'):
 validtypes = ['page', 'section']
 if (type not in validtypes):
  tmpl = 'Page break style "%s" not implemented. Valid styles: %s.'
  raise ValueError((tmpl % (type, validtypes)))
 pagebreak = makeelement('p')
 if (type == 'page'):
  run = makeelement('r')
  br = makeelement('br', attributes={'type': type})
  run.append(br)
  pagebreak.append(run)
 elif (type == 'section'):
  pPr = makeelement('pPr')
  sectPr = makeelement('sectPr')
  if (orient == 'portrait'):
   pgSz = makeelement('pgSz', attributes={'w': '12240', 'h': '15840'})
  elif (orient == 'landscape'):
   pgSz = makeelement('pgSz', attributes={'h': '12240', 'w': '15840', 'orient': 'landscape'})
  sectPr.append(pgSz)
  pPr.append(sectPr)
  pagebreak.append(pPr)
 return pagebreak

def pagebreak ( type = 'page' , orient = 'portrait' ) : validtypes = [ 'page' , 'section' ] if ( type not in validtypes ) : tmpl = 'Page break style "%s" not implemented. Valid styles: %s.' raise ValueError ( ( tmpl % ( type , validtypes ) ) ) pagebreak = makeelement ( 'p' ) if ( type == 'page' ) : run = makeelement ( 'r' ) br = makeelement ( 'br' , attributes = { 'type' : type } ) run . append ( br ) pagebreak . append ( run ) elif ( type == 'section' ) : pPr = makeelement ( 'pPr' ) sectPr = makeelement ( 'sectPr' ) if ( orient == 'portrait' ) : pgSz = makeelement ( 'pgSz' , attributes = { 'w' : '12240' , 'h' : '15840' } ) elif ( orient == 'landscape' ) : pgSz = makeelement ( 'pgSz' , attributes = { 'h' : '12240' , 'w' : '15840' , 'orient' : 'landscape' } ) sectPr . append ( pgSz ) pPr . append ( sectPr ) pagebreak . append ( pPr ) return pagebreak
insert a break .