# Accessing Regina from Python

All of Regina's objects, classes and methods belong to the module called `regina`. For instance, the main 3-manifold triangulation class is `regina.NTriangulation`, and the main routine to read a data file is `regina.readFileMagic`.

Whenever Regina gives you access to Python (either through a graphical console, a script packet or a command-line session), it will automatically import the `regina` module (i.e., “`import regina`”), and it will import all of Regina's objects, classes and methods into the current namespace (i.e., “`from regina import *`”).

This means, for instance, that you create a new triangulation by just calling `NTriangulation()`, and you can read a data file by calling `readFileMagic(filename)`. For command-line sessions, if you wish to avoid the heavy-handed “`from regina import *`”, you can pass the option `--noautoimport` (in which case you will need to use fully qualified names such as `regina.NTriangulation()` and `regina.readFileMagic(filename)`).

### Tip

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 `~/.regina-libs`, as described in the regina-python reference.

### Documentation

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 Help->Python API Reference 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.