This is only required when creating particularly exotic restricted environments that import modules in new ways. Here's a sample usage of a restricted environment. First, the RExec instance has to be created. The first line executes a statement, importing the string module. Since it's considered a safe module, the operation succeeds.
Unsafe operations trigger an exception.
Opening files for reading will work, however. It also restricts the variables and functions that are available from the sys and os modules. To change any of these policies, whether to be stricter or looser, see the section below on customizing the restricted environment.