move python demos to _pydemo
This commit is contained in:
23
_pydemo/clpy/cleval.go
Normal file
23
_pydemo/clpy/cleval.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
)
|
||||
|
||||
func main() {
|
||||
py.Initialize()
|
||||
py.SetProgramName(*c.Argv)
|
||||
code := py.CompileString(c.Str(`print('Hello, World!')`), c.Str(`hello.py`), py.EvalInput)
|
||||
if code != nil {
|
||||
mod := py.ImportModule(c.Str("__main__"))
|
||||
gbl := mod.GetDict()
|
||||
|
||||
result := py.EvalCode(code, gbl, nil)
|
||||
|
||||
result.DecRef()
|
||||
mod.DecRef()
|
||||
code.DecRef()
|
||||
}
|
||||
py.Finalize()
|
||||
}
|
||||
Reference in New Issue
Block a user