Skip to main content

SmartTitleTool: Flexible Smart Title Case Formatter

SmartTitleTool is a Python function designed to transform strings into flexible title case format while excluding specified words from capitalization. This simple yet powerful tool supports various input styles and offers unmatched flexibility for users with diverse formatting needs.

Features

  • Converts strings to a "flexible" title case format.
  • Allows exclusions for specific words (e.g., articles, prepositions).
  • Handles exclusions provided as:
    • A single word.
    • A list of words.
    • Multiple words as separate arguments.
  • Automatically normalizes exclusions to lowercase for consistency.

Importing the Function

from smarttitletool import SmartTitleTool

Example Usages

Example 1: Single exclusion word

formatter = SmartTitleTool("the")
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The Quick Brown Fox Jumps Over The Lazy Dog"

Example 2: Multiple exclusions as separate arguments

formatter = SmartTitleTool("the", "over", "jumps")
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The Quick Brown Fox Jumps over the Lazy Dog"

Example 3: Exclusions as a list

formatter = SmartTitleTool(["the", "over", "quick"])
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The quick Brown Fox Jumps over the Lazy Dog"

Example 4: Combining lists and strings

formatter = SmartTitleTool(["the", "over"], "jumps")
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The Quick Brown Fox jumps over the Lazy Dog"

Example 5: No exclusions

formatter = SmartTitleTool()
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The Quick Brown Fox Jumps Over The Lazy Dog"

Example 6: Dynamic word splitting

formatter = SmartTitleTool("brown over quick")
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The quick brown Fox Jumps over The Lazy Dog"

Example 7: Case insensitivity

formatter = SmartTitleTool("ThE", "OVer", "QUICK")
result = formatter.to_smart_title_case("the quick brown fox jumps over the lazy dog")
print(result)  # Output: "The quick Brown Fox Jumps over the Lazy Dog"

Example 8: First word always capitalized

formatter = SmartTitleTool("the", "and")
result = formatter.to_smart_title_case("and then there was light")
print(result)  # Output: "And Then There Was Light"

Example 9: Single word input

formatter = SmartTitleTool("the")
result = formatter.to_smart_title_case("fox")
print(result)  # Output: "Fox"

Example 10: Empty string input

formatter = SmartTitleTool("the")
result = formatter.to_smart_title_case("")
print(result)  # Output: ""

Example 11: Large input with many exclusions

exclusions = ["the", "over", "and", "a", "of", "in", "to", "on"]
formatter = SmartTitleTool(*exclusions)
text = "the history of art in the renaissance and its impact on society"
result = formatter.to_smart_title_case(text)
print(result)  # Output: "The History of Art in the Renaissance and Its Impact on Society"

API Reference

Function: SmartTitleTool

Constructor

SmartTitleTool(*exclusions)
  • exclusions (str, list, or multiple strings): Words to exclude from capitalization.

Method: to_smart_title_case

to_smart_title_case(text)
  • text (str): The input string to format.
  • Returns: A string formatted in flexible title case.

Author


License

This project is licensed under the MIT License.

Metadata

Release files for smarttitletool 1.0.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 smarttitletool 1.0.0
File Size Uploaded Provenance
smarttitletool-1.0.0.tar.gz 2.8 kB Without provenance Details

Release files / smarttitletool-1.0.0.tar.gz

Download URL smarttitletool-1.0.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ef688c17d81c2b0abda265fb8632c33dd12a50e28ab9959216745c8f1609d483
BLAKE2b-256 checksum
How to use checksums
d57d7925905ef4e5bd666521a6db0459fe58249c2526afc1ae106573dd7e5bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Security for smarttitletool 1.0.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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file 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