'Print the expression as code.
Parameters
expr : Expression
The expression to be printed.
assign_to : Symbol, MatrixSymbol, or string (optional)
If provided, the printed code will set the expression to a
variable with name ``assign_to``.'

def doprint(self, expr, assign_to=None):

    from sympy.matrices.expressions.matexpr import MatrixSymbol
    if isinstance(assign_to, string_types):
        if expr.is_Matrix:
            assign_to = MatrixSymbol(assign_to, *expr.shape)
        else:
            assign_to = Symbol(assign_to)
    elif (not isinstance(assign_to, (Basic, type(None)))):
        raise TypeError('{0}    cannot    assign    to    object    of    type    {1}'.format(type(self).__name__, type(assign_to)))
    if assign_to:
        expr = Assignment(assign_to, expr)
    else:
        expr = sympify(expr)
    self._not_supported = set()
    self._number_symbols = set()
    lines = self._print(expr).splitlines()
    if self._settings['human']:
        frontlines = []
        if (len(self._not_supported) > 0):
            frontlines.append(self._get_comment('Not    supported    in    {0}:'.format(self.language)))
            for expr in sorted(self._not_supported, key=str):
                frontlines.append(self._get_comment(type(expr).__name__))
        for (name, value) in sorted(self._number_symbols, key=str):
            frontlines.append(self._declare_number_const(name, value))
        lines = (frontlines + lines)
        lines = self._format_code(lines)
        result = '\n'.join(lines)
    else:
        lines = self._format_code(lines)
        num_syms = set([(k, self._print(v)) for (k, v) in self._number_symbols])
        result = (num_syms, self._not_supported, '\n'.join(lines))
    del self._not_supported
    del self._number_symbols
    return result
