Skip to main content

string-list

Tiny but powerful string <-> list manipulation utilities for Python.

string-list is a lightweight Python package designed to help you quickly and cleanly convert between strings, lists, sets, and more. It’s perfect for handling user input, CSV-style values, or transforming semi-structured data with minimal fuss.


✨ Features

  • ✅ Cleanly split strings into lists (with optional whitespace trimming)
  • ✅ Join lists/sets into delimited strings (with optional quoting)
  • ✅ Handle unknown input types (str, int, list) and normalize them
  • ✅ Case-insensitive set merging with capitalization preference
  • ✅ Dictionary enumeration with string keys for config-friendly output

📦 Installation

pip install string-list

Then in your Python code:

from string_list import list_from_string

🔧 Usage Examples

📌 list_from_string()

Split a string into a list with optional trimming:

from string_list import list_from_string

list_from_string("a,b,c")                    # ['a', 'b', 'c']
list_from_string(" a , b , c ", strip=True)  # ['a', 'b', 'c']
list_from_string("1|2|3", delim="|")         # ['1', '2', '3']

📌 string_from_list()

Join a list or set into a string:

from string_list import string_from_list

string_from_list(['a', 'b', 'c'])                     # "a,b,c"
string_from_list({'x', 'y'}, quoted=True)             # "'x','y'"
string_from_list([1, 2, 3], delim='|')                # "1|2|3"
string_from_list(['x', None, 'y'])                    # "x,y"

📌 list_from_any()

Convert a str, int, or list into a list of strings or integers:

from string_list import list_from_any

list_from_any("10,20,30", return_items_as_int=True)  # [10, 20, 30]
list_from_any(123)                                   # ['123']
list_from_any(['1', '2'])                            # ['1', '2']

📌 case_insensitive_update()

Merge two sets while ensuring case-insensitive uniqueness and preferring title-case:

from string_list import case_insensitive_update

base = {"Film", "Movie"}
new = {"film", "Cinema"}
case_insensitive_update(base, new)  # {'Film', 'Movie', 'Cinema'}

📌 str_enumerate()

Enumerate any string/list into a dictionary with string keys (great for config files or JSON):

from string_list import str_enumerate

str_enumerate("apple,banana", start=1)
# {'1': 'apple', '2': 'banana'}

str_enumerate(["x", "y"])
# {'0': 'x', '1': 'y'}

🧪 Running Tests

If cloning the repo locally:

pip install -r requirements-dev.txt
pytest tests/

📝 License

MIT Licensed – free to use, share, and modify.


🙌 Contributing

If you have improvements or new utility functions to add, feel free to open a pull request!

Metadata

Release files for string-list 0.1.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 string-list 0.1.0
File Size Uploaded
string_list-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for string-list 0.1.0
File Interpreter ABI Platform
string_list-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / string_list-0.1.0.tar.gz

Download URL string_list-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
75619c4effbbd2d6ac99626768066bc65ab2661631e9af809058778425d0aa53
BLAKE2b-256 checksum
How to use checksums
e87bc3eca3eb6b29ab52d25348a9ce25bcbe9b7a6cdb78d028dabb1d2306d0c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.0

Release files / string_list-0.1.0-py3-none-any.whl

Download URL string_list-0.1.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2eafbf0a70ca3329f8eab5fe696a67f41f093272533a1a232e02c234f871da2
BLAKE2b-256 checksum
How to use checksums
af951ecc8db46d11894a23c22a3839a4952b31bfa4ac969f3840437c23939140
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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