### 4.28.7 python_run

`Syntax:`
  `python_run (` string_expression `)`
`Type:`
  none
`Purpose:`
  Executes python commands (given as a string) in `python` context and syncs the contexts afterwards.
`Example:`

        LIB("pyobject.so");
      ==> no pyobject support
        python_run("def newfunc(*args): return list(args)");
      ==>    ? `python_run` is not defined
      ==>    ? error occurred in or before ./examples/python_run.sing line 2: `  py\
         thon_run("def newfunc(*args): return list(args)");`
        newfunc(1, 2, 3);          // newfunc also known to SINGULAR now
      ==>    ? `newfunc(1,2,3)` is undefined
      ==>    ? error occurred in or before ./examples/python_run.sing line 3: `  ne\
         wfunc(1, 2, 3);          // newfunc also known to SINGULAR now`

        python_run("import os");
      ==>    ? `python_run` is not defined
      ==>    ? error occurred in or before ./examples/python_run.sing line 5: `  py\
         thon_run("import os");`
        os;
      ==>    ? `os` is undefined
      ==>    ? error occurred in or before ./examples/python_run.sing line 6: `  os\
         ;`
        attrib(os, "name");
      ==>

User manual for Singular version 4.4.1, 2025, generated by texi2html.