A small utility function that expands a deque as needed and sets an item at the specified index, filling new positions with a user-specified value.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
expand-and-setitem
A small utility function that expands a deque as needed and sets an item at the specified index, filling new positions with a user-specified value.
Features
- Assign to any index (positive or negative) on a deque, even if it's out of range.
- Automatically expands and fills new slots as needed.
Usage
from collections import deque
from expand_and_setitem import expand_and_setitem
d = deque([1, 2, 3])
expand_and_setitem(
deque=d,
index=5,
value=99,
fillvalue=0
)
print(d) # deque([1, 2, 3, 0, 0, 99])
expand_and_setitem(
deque=d,
index=-8,
value=42,
fillvalue=None
)
print(d) # deque([42, None, 1, 2, 3, 0, 0, 99])
Installation
pip install expand-and-setitem
Why?
The standard Python deque doesn't allow setting values out of range. This utility removes the need to manually expand the deque before assignment.
License
MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file expand_and_setitem-0.1.0a0.tar.gz.
File metadata
- Download URL: expand_and_setitem-0.1.0a0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09badc854abfa63beae155fe8f27949e95c81e4185da2c6996a0d93590ac9158
|
|
| MD5 |
ea01090bcba203bba1e43e761eb4e53c
|
|
| BLAKE2b-256 |
03ec8e4cd706a2cb4703b301a333bf2af70b9996157ff946bcd12585d38752cb
|
File details
Details for the file expand_and_setitem-0.1.0a0-py2.py3-none-any.whl.
File metadata
- Download URL: expand_and_setitem-0.1.0a0-py2.py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34015ca9c1abd0069aa95a9e1bb934ded4f4f3d602b87dff34547a12d3000bc0
|
|
| MD5 |
0f087be08f9105f22125c2ddc48f3729
|
|
| BLAKE2b-256 |
a883d18f15fef65e836151ed6bbe141cf6303aead5ece38b7dcd23e0674387dd
|