py.import: Import a Python module

Description Usage Arguments Value Author(s) Examples

Description

py.import import a module and return a reference to the module.

Usage

1
py.import(module)

Arguments

module

string, name of the module

Value

Reference to the Python module. The `$` and `$<-` operators are supported to get/set values from/to the module - syntactic sugar for py.get, py.set.

Author(s)

Simon Urbanek

Examples

1
2
3
4
5
6
7
py.init()
main = py.import("__main__")
main$x = 1
py.eval("b = x + 1")
main$b
len = py.import("__builtin__")$len
len(1:10)

s-u/rpython documentation built on May 28, 2019, 10:48 a.m.