def within(self, other):
        """
        Tests if this range is within `other`.

            >>> a = intrange(1, 10)
            >>> b = intrange(3, 8)
            >>> a.contains(b)
            True
            >>> b.within(a)
            True

        This is the same as the ``self <@ other`` in PostgreSQL. One difference
        however is that unlike PostgreSQL ``self`` in this can't be a scalar
        value.

        :param other: Range to test against.
        :return: ``True`` if this range is completely within the given range,
                 otherwise ``False``.
        :raises TypeError: If given range is of the wrong type.

        .. seealso::
           This method is the inverse of :meth:`~spans.types.Range.contains`
        """

        if not self.is_valid_range(other):
            raise TypeError(
                "Unsupported type to test for inclusion '{0.__class__.__name__}'".format(
                    other))
        return other.contains(self)
Tests if this range is within `other`.

            >>> a = intrange(1, 10)
            >>> b = intrange(3, 8)
            >>> a.contains(b)
            True
            >>> b.within(a)
            True

        This is the same as the ``self <@ other`` in PostgreSQL. One difference
        however is that unlike PostgreSQL ``self`` in this can't be a scalar
        value.

        :param other: Range to test against.
        :return: ``True`` if this range is completely within the given range,
                 otherwise ``False``.
        :raises TypeError: If given range is of the wrong type.

        .. seealso::
           This method is the inverse of :meth:`~spans.types.Range.contains`