Is there any PythonForm ? to automate Sin[] to math.sin()?
If I where to do this manually, I would start with
PythonForm~SetAttributes~HoldAll
(*known symbols*)
PythonForm[Sin[x_]] := StringTemplate["math.sin(``)"]@PythonForm@x
PythonForm[Times[a_, b_]] :=
StringTemplate["(`` * ``)"][PythonForm@a, PythonForm@b]
(*fallback*)
PythonForm[x_] := ToString@x;
PythonForm[f_Symbol[args___]] :=
StringTemplate["``(``)"][ToString@f, PythonForm@args]
PythonForm[args___] := (PythonForm /@ {args})~StringRiffle~", ";
PythonForm[Sin[2 * Sin[x] * 4 * f[x, y]]]
"math.sin((2 * (math.sin(x) * (4 * f(x, y)))))"
Have a look at my solution to this problem, at: https://mathematica.stackexchange.com/a/144200/48312. I also prepared a Mathematica package for handling this at https://github.com/gwiederhecker/ToPython.