class_docstr: A printer to convert expressions to strings of Julia code.
class_docstr_tok: ["A","printer","to","convert","expressions","to","strings","of","Julia","code","."]
code: def _print_Piecewise(self, expr):
      if expr.args[-1].cond != True:
          # We need the last conditional to be a True, otherwise the resulting
          # function may not return a result.
          raise ValueError(
              "All Piecewise expressions must contain an "
              "(expr, True) statement to be used as a default "
              "condition. Without one, the generated "
              "expression may not evaluate to anything under "
              "some condition."
          )
      lines = []
      if self._settings["inline"]:
          # Express each (cond, expr) pair in a nested Horner form:
          #   (condition) .* (expr) + (not cond) .* (<others>)
          # Expressions that result in multiple statements won't work here.
          ecpairs = [
              "({}) ? ({}) :".format(self._print(c), self._print(e))
              for e, c in expr.args[:-1]
          ]
          elast = " (%s)" % self._print(expr.args[-1].expr)
          pw = "\n".join(ecpairs) + elast
          # Note: current need these outer brackets for 2*pw.  Would be
          # nicer to teach parenthesize() to do this for us when needed!
          return "(" + pw + ")"
      else:
          for i, (e, c) in enumerate(expr.args):
              if i == 0:
                  lines.append("if (%s)" % self._print(c))
              elif i == len(expr.args) - 1 and c == True:
                  lines.append("else")
              else:
                  lines.append("elseif (%s)" % self._print(c))
              code0 = self._print(e)
              lines.append(code0)
              if i == len(expr.args) - 1:
                  lines.append("end")
          return "\n".join(lines)
  
imports: from __future__ import annotations
  from typing import Any
  from sympy.core import Mul, Pow, S, Rational
  from sympy.core.mul import _keep_coeff
  from sympy.core.numbers import equal_valued
  from sympy.printing.codeprinter import CodePrinter
  from sympy.printing.precedence import precedence, PRECEDENCE
  from re import search
label_desc: Use image node_id 40 for calling the JuliaCodePrinter obj's underlying member method code with example usage: obj._print_Piecewise(expr) and returns: unknown, str