Skip to main content

iterstring

https://img.shields.io/pypi/v/iterstring.svg https://img.shields.io/travis/datagazing/iterstring.svg Documentation Status

Simple class that allows writing lists and dicts as heredoc strings

  • Write lists as strings with one line per element

  • Same for dictionaries, but use first token on each line as key

Features

  • Handles comments (using # characters)

  • Strips away extraneous whitespace with reasonable defaults (configurable)

  • Coerce items to numbers where possible (see coerce)

  • Iterating over the object treats it like a list

  • Indexing the object treats it like a dictionary

  • listr and distr helper functions provide simple interfaces

Examples

A simple use case:

>>> from iterstring import listr # or distr
>>> some_list = listr('''
item one # with a comment
  2
three
''')
>>> some_list
['item one', 2, 'three']
>>> type(some_list)
<class 'list'>

Using the class directly:

>>> from iterstring import Istr
>>> asdf = Istr('''
item one # with a comment
  2
three
''')
>>> asdf.to_list()
['item one', 2, 'three']
>>> type(asdf)
<class 'iterstring.Istr'>

>>> [x for x in asdf]
['item one', 2, 'three']

>>> fdsa = Istr('''
item one # with a comment
  2 some other value
key3 3.14159
''')
>>> asdf.to_dict()
{'item': 'one', 2: 'some other value', 'key3': 3.14159}
>>> asdf.to_dict(coerce=False)
{'item': 'one', '2': 'some other value', 'key3': '3.14159'}

License

  • Free software: MIT license

Documentation

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Metadata

Release files for iterstring 1.2.0

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

Source distribution (sdist)

Source distribution for iterstring 1.2.0
File Size Uploaded Provenance Actions
iterstring-1.2.0.tar.gz 11.5 kB Without provenance Details for iterstring-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for iterstring 1.2.0
File Interpreter ABI Platform Actions
iterstring-1.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for iterstring-1.2.0-py2.py3-none-any.whl

Total release size: 16.6 kB

Release files / iterstring-1.2.0.tar.gz

Download URL iterstring-1.2.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
146a7120a3173aa3f400ecb75c60cfa0febf364bf3455382c9e90bdbb146a2c7
BLAKE2b-256 checksum
How to use checksums
2a15712efe7b13943fbab019241091e3067ff1f5e9dc35ec971cb54ac856d0cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.25.1

Release files / iterstring-1.2.0-py2.py3-none-any.whl

Download URL iterstring-1.2.0-py2.py3-none-any.whl
Size 5.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4f75712cf903ef32f2c65c5fe35e1a39362dd3e4f4ede93a49abfeb8f85ceb9b
BLAKE2b-256 checksum
How to use checksums
487e3b86be0573563d97d6c905f1e49cc75793bdb6fec07e7c2b2582b862e9f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.25.1

Security for iterstring 1.2.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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