Skip to content

Commit 8acb886

Browse files
committed
returning ExternalFunction when the last expression is a class or a function
1 parent e28fb93 commit 8acb886

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

wolframclient/utils/externalevaluate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def execute_from_string(code, globals={}, **opts):
6464
if not expressions:
6565
return
6666

67-
if isinstance(last(expressions), ast.Expr):
67+
last_expr = last(expressions)
68+
69+
if isinstance(last_expr, ast.Expr):
6870
result = expressions.pop(-1)
6971

7072
if expressions:
@@ -73,6 +75,9 @@ def execute_from_string(code, globals={}, **opts):
7375
if result:
7476
return eval(compile(ast.Expression(result.value), "", "eval"), env)
7577

78+
elif isinstance(last_expr, (ast.FunctionDef, ast.ClassDef)):
79+
return env[last_expr.name]
80+
7681

7782
class SideEffectSender(logging.Handler):
7883
def emit(self, record):

0 commit comments

Comments
 (0)