def render_power(children):
 if (len(children) == 1):
  return children[0]
 children_latex = [k.latex for k in children if (k.latex != '^')]
 children_latex[(-1)] = children[(-1)].sans_parens
 raise_power = (lambda x, y: u'{}^{{{}}}'.format(y, x))
 latex = reduce(raise_power, reversed(children_latex))
 return LatexRendered(latex, tall=True)

def render_power ( children ) : if ( len ( children ) == 1 ) : return children [ 0 ] children_latex = [ k . latex for k in children if ( k . latex != '^' ) ] children_latex [ ( - 1 ) ] = children [ ( - 1 ) ] . sans_parens raise_power = ( lambda x , y : u'{}^{{{}}}' . format ( y , x ) ) latex = reduce ( raise_power , reversed ( children_latex ) ) return LatexRendered ( latex , tall = True )
combine powers so that the latex is wrapped in curly braces correctly .