api.printing.pycode#

Functions#

pycode(expr, **settings)

Converts an expr to a string of Python code

Classes#

Inheritance diagram of psydac.api.printing.pycode

PythonCodePrinter(*args, **kwargs)

Details#

class PythonCodePrinter(*args: Any, **kwargs: Any)[source]#

Bases: PythonCodePrinter

pycode(expr, **settings)[source]#

Converts an expr to a string of Python code

Parameters:
exprExpr

A SymPy expression.

fully_qualified_modulesbool

Whether or not to write out full module names of functions (math.sin vs. sin). default: True.

enable_dependencies: bool

Whether or not to print dependencies too (EvalField, Kernel, etc)

Examples

>>> from sympy import tan, Symbol
>>> from sympy.printing.pycode import pycode
>>> pycode(tan(Symbol('x')) + 1)
'math.tan(x) + 1'