smpl.wrap.pycode

smpl.wrap.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.

standardstr or None, optional

Only ‘python3’ (default) is supported. This parameter may be removed in the future.

Examples

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