py/README
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
)
|
||||
|
||||
func main() {
|
||||
py.Initialize()
|
||||
py.SetProgramName(*c.Argv)
|
||||
math := py.ImportModule(c.Str("math"))
|
||||
sqrt := math.GetAttrString(c.Str("sqrt"))
|
||||
sqrt2 := sqrt.CallOneArg(py.Float(2)).FloatAsDouble()
|
||||
c.Printf(c.Str("sqrt(2) = %f\n"), sqrt2)
|
||||
py.Finalize()
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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()
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
)
|
||||
|
||||
func main() {
|
||||
py.Initialize()
|
||||
py.SetProgramName(*c.Argv)
|
||||
py.RunSimpleString(c.Str(`print('Hello, World!')`))
|
||||
py.Finalize()
|
||||
}
|
||||
Reference in New Issue
Block a user