A range which automatically deals with either direction.
Project description
Better Range
A range which automatically deals with either direction.
Installation
pip install brange
Usage
Start is always inclusive and end is always exclusive. Step must be a positive integer, as it always steps toward the end. A negative value will result in an empty range.
Regular
from brange import brange
# This will create a list between 10 (inclusive) and -40 (exclusive)
# [10, 11, 12, ... -37, -38, -39]
[i for i in brange(10, -40)]
N-dimensional
from brange import nbrange
dimensions = [
(1, 10, 2), # X
(3, -2, 1), # Y
(-2, 5, 1), # Z
]
[xyz for xyz in nbrange(*dimensions)]
# This will result in a list as below:
# [
# (1, 3, -2),
# (1, 3, -1),
# ...
# (9, -1, 2),
# (9, -1, 3),
# (9, -1, 4),
# ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brange-1.1.0.post1.tar.gz
(1.9 kB
view hashes)
Built Distribution
Close
Hashes for brange-1.1.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0d285d68a157d8fb96b1c507760951cefe399f2b3b53de4a4b858d6c35c6ddd |
|
MD5 | 7119fcdd10d354ee343a2e432876b2b3 |
|
BLAKE2b-256 | 1e060b32fae50fe61b834a51082f06459284438d1eab8672997a25355fd5750c |