Accessing Regina from Python
All of Regina's objects, classes and methods belong to the
For instance, the main 3-manifold triangulation class is
regina.NTriangulation, and the main routine to
read a data file is
Whenever Regina gives you access to Python (either through a
a script packet or a
it will automatically import the
module (i.e., “
and it will import all of Regina's objects,
classes and methods into the current namespace
from regina import *”).
This means, for instance, that you create a new triangulation by just
NTriangulation(), and you can read a data file
For command-line sessions, if you wish to avoid the heavy-handed
from regina import *”, you can pass
--noautoimport (in which case you will need to
use fully qualified names such as
If you have code that you find yourself writing again and again, you can put it in a user library. Regina will run all of the code in all of your user libraries at the beginning of every Python session (including graphical consoles, script packets and regina-python).
User libraries are just ordinary Python files: you can maintain
the current list of enabled libraries through
Regina's Python options.
On GNU/Linux and MacOS X, if you prefer, you can also maintain this
list directly by editing the text file
as described in the
Regina includes a complete API reference for its calculation engine, which describes in detail the objects, classes and methods that it makes available through Python. To read this documentation, select → from the menu. The API reference should open in your web browser (where you can bookmark it if you like). You can also read it online at regina.sourceforge.net.
|Python Scripting||Up||Caveats and Traps|