github.com/goplus/llgo@v0.8.3/py/_demo/clpy/cleval.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/goplus/llgo/c"
     5  	"github.com/goplus/llgo/py"
     6  )
     7  
     8  func main() {
     9  	py.Initialize()
    10  	py.SetProgramName(*c.Argv)
    11  	code := py.CompileString(c.Str(`print('Hello, World!')`), c.Str(`hello.py`), py.EvalInput)
    12  	if code != nil {
    13  		mod := py.ImportModule(c.Str("__main__"))
    14  		gbl := mod.ModuleGetDict()
    15  
    16  		result := py.EvalCode(code, gbl, nil)
    17  
    18  		result.DecRef()
    19  		mod.DecRef()
    20  		code.DecRef()
    21  	}
    22  	py.Finalize()
    23  }