Reference implementation of Python's list slicing resolution
Project description
Python Slicing Reference
Python's builtin list
type allows one to pass in slices
to get, set or delete a range of elements.
>>> my_list = ['a', 'b','c']
>>> my_list[0:2]
['a', 'b']
>>> my_list[0:3:2]
['a', 'b']
>>> my_list[1:3] = [1, 2]
>>> my_list
['a', 1, 2]
>>> my_list[::-1] = ['z', 'y', 'x']
>>> my_list
['x', 'y', 'z']
The slice notation using colons is infact a slice
builtin,
where start:stop:step
is equivalent to slice(start, stop, step)
.
This looks an awful lot like the range(start, stop, step)
builtin,
but 1-to-1 translating slices to ranges is not always appropiate.
I have created this package as a reference implementation of list
,
specifically to educate on how it deals with slices.
I use Hypothesis
to test my custom class listy
against Python's very own list
,
hopefully ensuring that all situations where slicing is involved
is perfectly emulated.
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
Hashes for slice_ref-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dcde661a32b9b9f6daf384a417c783fdcdd07d13db6cc3f74851a93fdad8fba |
|
MD5 | 981624f249f56262966f86d7d57ee820 |
|
BLAKE2b-256 | 4b666bc79bd6e28e3cac1cd4b0c66f457904919bc2f09c5ef70d5a3677b7afe8 |