#### 4.1.1 Modes

There are five different conversion modes, identified by the following constants (provided by the `rpy` module) and another constant to indicate the absence of a global mode:

- `PROC_CONVERSION`
- `CLASS_CONVERSION`
- `BASIC_CONVERSION`
- `VECTOR_CONVERSION`
- `NO_CONVERSION`
- `NO_DEFAULT`

The `rpy` module provides three functions for manipulating the conversion modes:

`get_default_mode()`

  Get the default conversion mode. It returns some of the previous constants (actually, an integer from the set {-1,0,1,2}, but you should use the literal constant rather than the numeric value).

`set_default_mode(m)`

  Set the default conversion mode to `m`.

`with_mode(m, fun)`

  Wrap the function `fun` in the conversion mode `m`. It returns a new function which accepts the same parameters as `fun` but, when called, it is evaluated in the conversion mode `m`. For example:

      >>> set_default_mode(BASIC_CONVERSION)
      >>> r.seq(1,3)
      [1, 2, 3]
      >>> with_mode(NO_CONVERSION, r.seq)(1,3)
      <Robj object at 0x8acb2a0>

The result of a call to a `Robj` object is converted according to the following rules:

1. If the default mode has a value in the set {`PROC_CONVERSION`, `CLASS_CONVERSION`, `BASIC_CONVERSION`, `NO_CONVERSION`}, that mode is used.
2. If the default mode has the value `NO_DEFAULT`, then the object’s local mode is used.
3. When an object cannot be converted in some mode (global or local), the object fall through to the next mode. The `NO_CONVERSION` mode always succeed returning a “pure” `Robj` object.

At startup the default mode is set to `NO_DEFAULT`, which means that each object has its own conversion mode, and every `Robj` object is retrieved with a local mode set to `PROC_CONVERSION`.