Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sliceparser

Introduction

As per this question, creating from string slice object, or even advanced indexing tuple, is a common requirement. However, there exists few robust and safe solution, if at all, to solve the problem. Therefore I attempt to solve it and expose programmatic interface via PyPI. I also put my answer to the question above.

This repo is adapted from my Gist.

Install

pip install sliceparser
# or pip3 install sliceparser

Usage

import sliceparser
a = [1,2,3,4]
assert a[sliceparser.parse_slice('2:')] == a[2:]
assert a[sliceparser.parse_slice('::2')] == a[::2]
assert a[sliceparser.parse_slice('1')] == a[1]

import numpy as np
A = np.eye(3)
assert np.array_equal(A[sliceparser.parse_slice('0, 1:')], A[0,1:])
assert np.array_equal(A[sliceparser.parse_slice('..., 2')], A[..., 2])

etc.

Release files for sliceparser 0.9.1b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sliceparser 0.9.1b0
File Size Uploaded
sliceparser-0.9.1b0.tar.gz 3.1 kB Details

Release files / sliceparser-0.9.1b0.tar.gz

Download URL sliceparser-0.9.1b0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
172a316b6e03ce3c5e7d1fbf68460ca1300ed097595481dfe26548a178ba0de8
BLAKE2b-256 checksum
How to use checksums
a8ae80507d2962365f02ce17dad0e82206c6addc1c562a03a459fb934aa09bd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.9.1b0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page