On this page:
run
run*

7 Evaluation

procedure

(run string-to-evaluate)  obj?

  string-to-evaluate : string?
Evaluate the string string-to-evaluate in the running Python interpreter. The string must contain a Python expression. The expression is evaluated in the "main" module.

The resulting Python object is converted to a Racket value via pr.

If an exception is triggered on the Python side, a Racket exception is raised containing the error message and the traceback.

> (run "[1+10, '2'+'20', (3,30), {4: 40}]")

(obj "list" : [11, '220', (3, 30), {4: 40}])

> (run "x = 'this is not an expression'")

run: Python exception occurred;

   File "<string>", line 1

     x = 'this is not an expression'

       ^

 SyntaxError: invalid syntax

procedure

(run* string-to-evaluate)  void?

  string-to-evaluate : string?
Evaluate the string string-to-evaluate in the running Python interpreter. The string must contain a Python statement. The statement is executed in the "main" module.

If an exception is triggered on the Python side, a Racket exception is raised containing the error message and the traceback.

> (run* "x = 1+10")
> main.x

11