Top-level package for iterstring.
Project description
Simple class that allows writing lists and dicts as heredoc strings
Free software: MIT license
Documentation: https://iterstring.readthedocs.io.
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 functions are simplest interfaces
Examples
>>> from iterstring import Listr # or Distr
A simple use case:
>>> 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'}
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
iterstring-0.1.0.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for iterstring-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92a219edaf04bb82970ff5bc93c6abef012779a11c56ff31b4be8d7baff844db |
|
MD5 | ddc3dd1fe51a61a84b9b32a64365e641 |
|
BLAKE2b-256 | 5573ba61af3163ad92a1527591c2fe9a4bcfc75bbc64504fa1268cf446bcf2c5 |