class documentation

An extension of the built-in ``range()`` function whose arguments can be any orderable numeric type. With only *stop* specified, *start* defaults to ``0`` and *step* defaults to ``1``. The output items will match the type of *stop*: >>> list(numeric_range(3.5)) [0.0, 1.0, 2.0, 3.0] With only *start* and *stop* specified, *step* defaults to ``1``. The output items will match the type of *start*: >>> from decimal import Decimal >>> start = Decimal('2.1') >>> stop = Decimal('5.1') >>> list(numeric_range(start, stop)) [Decimal('2.1'), Decimal('3.1'), Decimal('4.1')] With *start*, *stop*, and *step* specified the output items will match the type of ``start + step``: >>> from fractions import Fraction >>> start = Fraction(1, 2) # Start at 1/2 >>> stop = Fraction(5, 2) # End at 5/2 >>> step = Fraction(1, 2) # Count by 1/2 >>> list(numeric_range(start, stop, step)) [Fraction(1, 2), Fraction(1, 1), Fraction(3, 2), Fraction(2, 1)] If *step* is zero, ``ValueError`` is raised. Negative steps are supported: >>> list(numeric_range(3, -1, -1.0)) [3.0, 2.0, 1.0, 0.0] Be aware of the limitations of floating point numbers; the representation of the yielded numbers may be surprising. ``datetime.datetime`` objects can be used for *start* and *stop*, if *step* is a ``datetime.timedelta`` object: >>> import datetime >>> start = datetime.datetime(2019, 1, 1) >>> stop = datetime.datetime(2019, 1, 3) >>> step = datetime.timedelta(days=1) >>> items = iter(numeric_range(start, stop, step)) >>> next(items) datetime.datetime(2019, 1, 1, 0, 0) >>> next(items) datetime.datetime(2019, 1, 2, 0, 0)

Method __bool__ Undocumented
Method __contains__ Undocumented
Method __eq__ Undocumented
Method __getitem__ Undocumented
Method __hash__ Undocumented
Method __init__ Undocumented
Method __iter__ Undocumented
Method __len__ Undocumented
Method __reduce__ Undocumented
Method __repr__ Undocumented
Method __reversed__ Undocumented
Method count Undocumented
Method index Undocumented
Method _get_by_index Undocumented
Method _init_len Undocumented
Constant _EMPTY_HASH Undocumented
Instance Variable _growing Undocumented
Instance Variable _len Undocumented
Instance Variable _start Undocumented
Instance Variable _step Undocumented
Instance Variable _stop Undocumented
Instance Variable _zero Undocumented
def __bool__(self): (source)

Undocumented

def __contains__(self, elem): (source)

Undocumented

def __eq__(self, other): (source)

Undocumented

def __getitem__(self, key): (source)

Undocumented

def __hash__(self): (source)

Undocumented

def __init__(self, *args): (source)

Undocumented

def __iter__(self): (source)

Undocumented

def __len__(self): (source)

Undocumented

def __reduce__(self): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def __reversed__(self): (source)

Undocumented

def count(self, value): (source)

Undocumented

def index(self, value): (source)

Undocumented

def _get_by_index(self, i): (source)

Undocumented

def _init_len(self): (source)

Undocumented

_EMPTY_HASH = (source)

Undocumented

Value
hash(range(0, 0))
_growing = (source)

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented