pyexec
| pyexec | 
  Purpose
 
  
  Synopsis
 
  procedure pyexec(code:string) 
 
  Argument
 
 | 
     code 
     | 
     Python statements to execute
     | 
  Example
 
 
  The following model runs Python statements from a string:
 
  model "Python script from string"
   uses "python3"
   writeln("Python version:")
   pyexec("import platform; print(platform.python_version())")
 end-model
  Further information
 
 
 1. This function compiles and runs a Python script from a string buffer and waits for its termination. It is a fatal error if the compilation fails or if a Python run-time error occurs.
 
 
 2. Use the I/O
  Driver python  and the functions
 pyget and
 pyset to transfer data between Mosel and Python. Use
 pyget to evaluate a single expression with return value and use
 pycall to call a single function with input arguments or return value.
 
 
 3. Do not concatenate untrusted strings from the end user into the
 code string. See Section
 Xpress Insight configuration for more information.
 
 
  Related topics
 
  
  Module
 
 
 python3
 
 
