class_docstr: The base class for code-printing subclasses.
class_docstr_tok: ["The","base","class","for","code-printing","subclasses","."]
docstr: Print the expression as code.
  
  Parameters
  ----------
  expr : Expression
      The expression to be printed.
  
  assign_to : Symbol, string, MatrixSymbol, list of strings or Symbols (optional)
      If provided, the printed code will set the expression to a variable or multiple variables
      with the name or names given in ``assign_to``.
docstr_tok: ["Print","the","expression","as","code",".","Parameters","--","--","--","--","--","expr",":","Expression","The","expression","to","be","printed",".","assign_to",":","Symbol",",","string",",","MatrixSymbol",",","list","of","strings","or","Symbols","(","optional",")","If","provided",",","the","printed","code","will","set","the","expression","to","a","variable","or","multiple","variables","with","the","name","or","names","given","in","``","assign_to","``","."]
code: def doprint(self, expr, assign_to=None):
      """
      Print the expression as code.
  
      Parameters
      ----------
      expr : Expression
          The expression to be printed.
  
      assign_to : Symbol, string, MatrixSymbol, list of strings or Symbols (optional)
          If provided, the printed code will set the expression to a variable or multiple variables
          with the name or names given in ``assign_to``.
      """
      from sympy.matrices.expressions.matexpr import MatrixSymbol
      from sympy.codegen.ast import CodeBlock, Assignment
  
      def _handle_assign_to(expr, assign_to):
          if assign_to is None:
              return sympify(expr)
          if isinstance(assign_to, (list, tuple)):
              if len(expr) != len(assign_to):
                  raise ValueError(
                      "Failed to assign an expression of length {} to {} variables".format(
                          len(expr), len(assign_to)
                      )
                  )
              return CodeBlock(
                  *[
                      _handle_assign_to(lhs, rhs)
                      for lhs, rhs in zip(expr, assign_to)
                  ]
              )
          if isinstance(assign_to, str):
              if expr.is_Matrix:
                  assign_to = MatrixSymbol(assign_to, *expr.shape)
              else:
                  assign_to = Symbol(assign_to)
          elif not isinstance(assign_to, Basic):
              raise TypeError(
                  "{} cannot assign to object of type {}".format(
                      type(self).__name__, type(assign_to)
                  )
              )
          return Assignment(assign_to, expr)
  
      expr = _convert_python_lists(expr)
      expr = _handle_assign_to(expr, assign_to)
  
      # Remove re(...) nodes due to UnevaluatedExpr.is_real always is None:
      expr = self._handle_UnevaluatedExpr(expr)
  
      # keep a set of expressions that are not strictly translatable to Code
      # and number constants that must be declared and initialized
      self._not_supported = set()
      self._number_symbols = set()
  
      lines = self._print(expr).splitlines()
  
      # format the output
      if self._settings["human"]:
          frontlines = []
          if self._not_supported:
              frontlines.append(
                  self._get_comment(
                      "Not supported in {}:".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 = {
              (k, self._print(v)) for k, v in self._number_symbols
          }
          result = (num_syms, self._not_supported, "\n".join(lines))
      self._not_supported = set()
      self._number_symbols = set()
      return result
  
imports: from __future__ import annotations
  from typing import Any
  from functools import wraps
  from sympy.core import Add, Mul, Pow, S, sympify, Float
  from sympy.core.basic import Basic
  from sympy.core.expr import UnevaluatedExpr
  from sympy.core.function import Lambda
  from sympy.core.mul import _keep_coeff
  from sympy.core.sorting import default_sort_key
  from sympy.core.symbol import Symbol
  from sympy.functions.elementary.complexes import re
  from sympy.printing.str import StrPrinter
  from sympy.printing.precedence import precedence, PRECEDENCE
label_desc: Use image node_id 3 for calling the CodePrinter obj's underlying member method code with example usage: obj.doprint(expr, assign_to) and returns: result, Assignment, sympify, CodeBlock