Metadata-Version: 2.4
Name: polyslice
Version: 0.0.2
Summary: Extends Python indexing with multiple slices and indices in one operation, concatenating the selections into a new sequence of the original type.
Author-email: Bas Terwijn <bterwijn@gmail.com>
License-Expression: BSD-2-Clause
Project-URL: Homepage, https://github.com/bterwijn/polyslice
Project-URL: Repository, https://github.com/bterwijn/polyslice
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# polyslice
Extends Python indexing with multiple slices and indices in one operation, concatenating the selections into a new sequence of the original type.

```python
from polyslice import PolySlice
    
data = "0123456789"

a = PolySlice(data)[0:3, 5, -1:-3:-1]
print(a)  # 012578

b = PolySlice(tuple(data))[0:3, 5, -1:-3:-1]
print(b)  # ('0', '1', '2', '5', '9', '8')

c = PolySlice(list(data))[0:3, 5, -1:-3:-1]
print(c)  # ['0', '1', '2', '5', '9', '8']
```

## Interface
To make polyslice work on your own containers, implement:

```python
class MyContainer:

    def __init__(self, iterable=()) -> None:
        ...

    def __iadd__(self, other: Self) -> Self:
        ...

    def __getitem__(self, key: int | slice) -> object | Self:
        ...
```

Or alternatively, convert to and from polysliceble iterable (tuple, list, ...), by implementing:

```python
class MyContainer:

    def to_iterable(self) -> polysliceble_iterable:
        ...

    @classmethod
    def from_iterable(cls, iterable) -> Self:
        ...
```
