Metadata-Version: 2.4
Name: expand-and-setitem
Version: 0.1.0a0
Summary: 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.
Author-email: Jifeng Wu <jifengwu2k@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/jifengwu2k/expand-and-setitem
Project-URL: Bug Tracker, https://github.com/jifengwu2k/expand-and-setitem/issues
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=2
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typing; python_version < "3.5"
Dynamic: license-file

# `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

```python
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


```bash
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
