Macaulay2 » Documentation
Packages » Python :: import
next | previous | forward | backward | up | index | toc

import -- import a Python module

Synopsis

Description

This is a wrapper around the Python C API function PyImport_ImportModule and returns an imported Python module.

Once imported, the statements and definitions from the module are available using getattr.

i1 : math = import "math"

o1 = <module 'math' (built-in)>

o1 : PythonObject of class module
i2 : getattr(math, "pi")

o2 = 3.141592653589793

o2 : PythonObject of class float
i3 : math@@sqrt 2

o3 = 1.4142135623730951

o3 : PythonObject of class float

Ways to use import :

For the programmer

The object import is a method function.