class documentation

class Range(Generic[_T]): (source)

View In Hierarchy

Represent a PostgreSQL range. E.g.:: r = Range(10, 50, bounds="()") The calling style is similar to that of psycopg and psycopg2, in part to allow easier migration from previous SQLAlchemy versions that used these objects directly. :param lower: Lower bound value, or None :param upper: Upper bound value, or None :param bounds: keyword-only, optional string value that is one of ``"()"``, ``"[)"``, ``"(]"``, ``"[]"``. Defaults to ``"[)"``. :param empty: keyword-only, optional bool indicating this is an "empty" range .. versionadded:: 2.0

Method __add__ Undocumented
Method __bool__ Undocumented
Method __eq__ Compare this range to the `other` taking into account bounds inclusivity, returning ``True`` if they are equal.
Method __init__ Undocumented
Method __str__ Undocumented
Method __sub__ Undocumented
Method adjacent_to Determine whether this range is adjacent to the `other`.
Method contained_by Determine whether this range is a contained by `other`.
Method contains Determine whether this range contains `value`.
Method difference Compute the difference between this range and the `other`.
Method not_extend_left_of Determine whether this does not extend to the left of `other`.
Method not_extend_right_of Determine whether this does not extend to the right of `other`.
Method overlaps Determine whether this range overlaps with `other`.
Method strictly_left_of Determine whether this range is completely to the left of `other`.
Method strictly_right_of Determine whether this range is completely to the right of `other`.
Method union Compute the union of this range with the `other`.
Class Variable bounds Undocumented
Class Variable empty Undocumented
Class Variable lower the lower bound
Class Variable upper the upper bound
Property __sa_type_engine__ Undocumented
Property is_empty A synonym for the 'empty' attribute.
Property isempty A synonym for the 'empty' attribute.
Property lower_inc Return True if the lower bound is inclusive.
Property lower_inf Return True if this range is non-empty and lower bound is infinite.
Property upper_inc Return True if the upper bound is inclusive.
Property upper_inf Return True if this range is non-empty and the upper bound is infinite.
Method _compare_edges Compare two range bounds.
Method _contains_value Return True if this range contains the given value.
Method _get_discrete_step Determine the “step” for this range, if it is a discrete one.
Method _stringify Undocumented
Method _upper_edge_adjacent_to_lower Determine whether an upper bound is immediately successive to a lower bound.
def __add__(self, other: Range[_T]) -> Range[_T]: (source)

Undocumented

def __bool__(self) -> bool: (source)

Undocumented

def __eq__(self, other: Any) -> bool: (source)

Compare this range to the `other` taking into account bounds inclusivity, returning ``True`` if they are equal.

def __init__(self, lower: Optional[_T] = None, upper: Optional[_T] = None, *, bounds: _BoundsType = '[)', empty: bool = False): (source)

Undocumented

def __str__(self) -> str: (source)

Undocumented

def __sub__(self, other: Range[_T]) -> Range[_T]: (source)

Undocumented

def adjacent_to(self, other: Range[_T]) -> bool: (source)

Determine whether this range is adjacent to the `other`.

def contained_by(self, other: Range[_T]) -> bool: (source)

Determine whether this range is a contained by `other`.

def contains(self, value: Union[_T, Range[_T]]) -> bool: (source)

Determine whether this range contains `value`.

def difference(self, other: Range[_T]) -> Range[_T]: (source)

Compute the difference between this range and the `other`. This raises a ``ValueError`` exception if the two ranges are "disjunct", that is neither adjacent nor overlapping.

def not_extend_left_of(self, other: Range[_T]) -> bool: (source)

Determine whether this does not extend to the left of `other`.

def not_extend_right_of(self, other: Range[_T]) -> bool: (source)

Determine whether this does not extend to the right of `other`.

def overlaps(self, other: Range[_T]) -> bool: (source)

Determine whether this range overlaps with `other`.

def strictly_left_of(self, other: Range[_T]) -> bool: (source)

Determine whether this range is completely to the left of `other`.

def strictly_right_of(self, other: Range[_T]) -> bool: (source)

Determine whether this range is completely to the right of `other`.

def union(self, other: Range[_T]) -> Range[_T]: (source)

Compute the union of this range with the `other`. This raises a ``ValueError`` exception if the two ranges are "disjunct", that is neither adjacent nor overlapping.

bounds: _BoundsType = (source)

Undocumented

Undocumented

lower: Optional[_T] = (source)

the lower bound

upper: Optional[_T] = (source)

the upper bound

@property
__sa_type_engine__: AbstractRange[Range[_T]] = (source)

Undocumented

A synonym for the 'empty' attribute.

A synonym for the 'empty' attribute.

Return True if the lower bound is inclusive.

Return True if this range is non-empty and lower bound is infinite.

Return True if the upper bound is inclusive.

Return True if this range is non-empty and the upper bound is infinite.

def _compare_edges(self, value1: Optional[_T], bound1: str, value2: Optional[_T], bound2: str, only_values: bool = False) -> int: (source)

Compare two range bounds. Return -1, 0 or 1 respectively when `value1` is less than, equal to or greater than `value2`. When `only_value` is ``True``, do not consider the *inclusivity* of the edges, just their values.

def _contains_value(self, value: _T) -> bool: (source)

Return True if this range contains the given value.

def _get_discrete_step(self) -> Any: (source)

Determine the “step” for this range, if it is a discrete one.

def _stringify(self) -> str: (source)

Undocumented

def _upper_edge_adjacent_to_lower(self, value1: Optional[_T], bound1: str, value2: Optional[_T], bound2: str) -> bool: (source)

Determine whether an upper bound is immediately successive to a lower bound.