Hey, there. It seems like it's not possible to define multiple classes in a single Python file with py.RunSrc(), unless I'm misunderstanding something...? It works with py.RunFile(), though.
Go:
context := py.NewContext(py.DefaultContextOpts())
data, _ := fs.ReadFile(g.FS, "math_stuff.py")
_, err := py.RunSrc(context, string(data), "run", nil)
log.Println(err)
math_stuff.py
class A:
pass
class B:
pass
Gives me the error:
2026/07/02 15:06:16
File "run", line 5, offset 5
class B:
SyntaxError: 'invalid syntax'
I'm testing with the latest commit.
Reactions are currently unavailable
Hey, there. It seems like it's not possible to define multiple classes in a single Python file with py.RunSrc(), unless I'm misunderstanding something...? It works with py.RunFile(), though.
Go:
math_stuff.py
Gives me the error:
2026/07/02 15:06:16 File "run", line 5, offset 5 class B: SyntaxError: 'invalid syntax'I'm testing with the latest commit.