Skip to main content

Strast

Strast is a versatile Python tool that transforms a string representation of a Python literal into the corresponding Python object, building upon the powerful ast module. The word "strast" also denotes "passion", reflecting our enthusiasm for data transformation.

Features

  • Transform string literals to Python objects seamlessly with the power of the ast module.
  • Flexible type checking to ensure data integrity.
  • Supports extensibility through factory and class-based approaches.

Installation

To install Strast, use pip:

pip install strast

Usage

import strast

Function

strasts core function:

result = strast.c("{'a': 1, 'b': 2}", dict) # or strast.core.strast
print(result)
print(strast("{'a': 1, 'b': 2}", list))

Output:

{'a': 1, 'b': 2}
TypeError: Expected <class 'list'>, got <class 'dict'> instead.

Factory

strast as a closure factory function:

strast = strast.f(dict, list, tuple) # or strast.factory.strast
print(strast("{'a': 1, 'b': 2}"))
print(strast("[1, 2, 3]"))
print(strast("('a', 'b', 'c')"))

Output:

{'a': 1, 'b': 2}
[1, 2, 3]
('a', 'b', 'c')

Class-based

strast as a class:

strast = strast.S(dict) # or strast.class_based.Strast
print(strast.transform("{'a': 1, 'b': 2}"))

Output:

{'a': 1, 'b': 2}

See also documentation

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Strast is licensed under the MIT license.

Metadata

Release files for strast 0.1.1

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

Source distribution (sdist)

Source distribution for strast 0.1.1
File Size Uploaded Provenance
strast-0.1.1.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for strast 0.1.1
File Interpreter ABI Platform
strast-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / strast-0.1.1.tar.gz

Download URL strast-0.1.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
db8f6fb784c50fb0afd2642be83006e966901e635d637a5e576178743622e3c0
BLAKE2b-256 checksum
How to use checksums
d756d7a0ddb6e9f017d0aeb0d0666cbee907bda65f35d108c1f8fdc632bf4205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / strast-0.1.1-py3-none-any.whl

Download URL strast-0.1.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
455326e203e14e1006559bbf463606612df294d3703eaf2ad0bcfb842ad9d5a2
BLAKE2b-256 checksum
How to use checksums
64ad1e41af98655a4ee28058ffddaf2ccefbdc6e6f524a2678840f46ba49e73b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for strast 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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