Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.142s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.114s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
is_email
✓ from string_utils import is_email
✗ from string_utils.validation import is_email
While importing from submodules like `string_utils.validation` works, the library makes all public API functions directly importable from the top-level `string_utils` package for convenience.
prettify
✓ from string_utils import prettify
Functions for string manipulation are available directly from the top-level package.
The quickstart demonstrates importing and using core validation and manipulation functions like `is_email`, `prettify`, and `is_full_string`. All public API functions are importable directly from the `string_utils` package.
from string_utils import is_email, prettify, is_full_string
# Example 1: Validate an email address
email = "test@example.com"
print(f"'{email}' is a valid email: {is_email(email)}")
# Example 2: Prettify a string
unprettified_string = " unprettified string ,, like this one,will be\"prettified\" . it' s awesome! "
prettified_string = prettify(unprettified_string)
print(f"Original: '{unprettified_string}'")
print(f"Prettified: '{prettified_string}'")
# Example 3: Check for non-empty string
empty_string = ""
non_empty_string = "hello"
print(f"'{empty_string}' is a full string: {is_full_string(empty_string)}")
print(f"'{non_empty_string}' is a full string: {is_full_string(non_empty_string)}")
Debug
Known issues
gotchaThe library has not been updated since March 2020 (version 1.0.0) and was last tested against Python versions 3.5-3.8. While it may still function on newer Python versions, active development and official compatibility for Python 3.9+ are not guaranteed, which could lead to unforeseen issues or a lack of support for modern Python features.fixFor new projects, consider modern alternatives within Python's standard library (e.g., f-strings, `pathlib` for path manipulation) or more actively maintained string utility libraries. If using this library, thorough testing on your target Python version is recommended.
affects: 1.0.0 (Python 3.9+)
gotchaMany string manipulation and validation tasks can now be handled efficiently and often more 'pythonically' using built-in Python features such as f-strings for formatting, the `re` module for complex regex patterns, and `pathlib` for robust path operations. Relying heavily on older utility libraries for these tasks might introduce unnecessary dependencies or overlook more idiomatic Python solutions.fixEvaluate if a specific `python-string-utils` function provides unique value compared to current Python standard library features (e.g., `str` methods, `re`, `pathlib`). Prioritize standard library solutions where they meet requirements for better maintainability and fewer external dependencies.
affects: All versions
gotchaThe `is_string` function specifically checks if an object is of type `str` and returns `False` for byte strings (`bytes`). This might be a footgun if you expect it to validate any string-like object, including byte strings, which are common in I/O or network operations.fixBe explicit about the string type you are expecting. If byte strings are a possibility, check `isinstance(obj, (str, bytes))` or convert byte strings to `str` before validation, e.g., `obj.decode('utf-8')`. affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'python_string_utils'
The `pip install` package name `python-string-utils` (with hyphens) differs from the importable Python module name `string_utils` (with underscores/no hyphens).
fixUse `import string_utils` or `from string_utils import ...` instead.
SyntaxError: invalid syntax
Python module names cannot contain hyphens, so `import python-string-utils` is syntactically invalid. The correct module name to import is `string_utils`.
fixChange the import statement to `import string_utils` or `from string_utils import ...`.
AttributeError: module 'string_utils' has no attribute 'is_email_valid'
The `string_utils` library does not have a function named `is_email_valid`. The correct function for email validation is `is_email`.
fixUse the correct function name: `from string_utils import is_email` and then call `is_email(...)`.
TypeError: expected string or bytes-like object
A function in `string_utils` (e.g., `is_email`, `camel_to_snake_case`) was called with an argument that is not a string, such as an integer, boolean, or `None`.
fixEnsure that the argument passed to the function is a string, for example: `string_utils.is_email('test@example.com')` or `string_utils.camel_to_snake_case(str(some_variable))`. Upgrade
Version history
1.0.0latest on PyPI · released Mar 4, 2020
Audit
Dependencies
No dependency data recorded yet.