Skip to main content

Text gadgets that help with indentation and a few other gizmos

Project description

Latest Version Python Versions Build Status Documentation Status

snick

Handy gadgets for taming indented text

Stop wrestling with indented triple-quoted strings and awkward text formatting. snick makes it effortless to:

  • Dedent triple-quoted strings while keeping your code beautifully indented
  • Build complex multi-line output programmatically with the powerful Conjoiner class
  • Format data structures with clean indentation and trailing commas
  • Clean up terminal output by stripping ANSI codes and whitespace
  • Wrap and indent long text blocks for logs and reports

All with zero dependencies.

Quickstart

Requirements

  • Python 3.10 or greater

Installation

Install the latest release from PyPI:

pip install snick

Usage

Ever struggle with indented triple-quoted strings in your code?

import snick

def my_function():
    return snick.dedent(
        """
        Oops! Something went wrong.
        Here's what happened:
            - The flux capacitor overheated
            - Time circuits malfunctioned
        Please try again later.
        """
    )

print(my_function())

Output:

Oops! Something went wrong.
Here's what happened:
    - The flux capacitor overheated
    - Time circuits malfunctioned
Please try again later.

Build complex output on the fly:

def generate_report(name, tasks):
    report = snick.Conjoiner()
    report.add(f"Daily Report for {name}", blanks_after=1)

    if tasks:
        report.add("Completed Tasks:")
        report.extend(f"  ✓ {task}" for task in tasks)
    else:
        report.add("No tasks completed today.")

    return str(report)

print(generate_report("Alice", ["Fix bug #123", "Review PR #456", "Deploy v2.0"]))

Output:

Daily Report for Alice

Completed Tasks:
  ✓ Fix bug #123
  ✓ Review PR #456
  ✓ Deploy v2.0

Format data structures with proper indentation:

data = {
    'user': 'bob',
    'permissions': ['read', 'write', 'execute'],
    'metadata': {'created': '2026-01-22', 'active': True}
}
print(snick.pretty_format(data))

Output:

{
  'user': 'bob',
  'permissions': [
    'read',
    'write',
    'execute',
  ],
  'metadata': {
    'created': '2026-01-22',
    'active': True,
  },
}

Documentation

The complete documentation can be found at the snick documentation page

What's with the name?

There's really no very good synonyms for the verb, 'indent'. However, there are several for the act of creating a small dent in something. One of my favorites was 'snick'. It means "to cut a small notch or incision in". I think I'll use that!

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

snick-3.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snick-3.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file snick-3.1.0.tar.gz.

File metadata

  • Download URL: snick-3.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for snick-3.1.0.tar.gz
Algorithm Hash digest
SHA256 63a87bc36964f7603d71d1a7a1ceccb379c7aa35747dd15c941f0c20701b6cc1
MD5 24943102193af89fde4279a2c524342a
BLAKE2b-256 e97bca10d1384c402ba6955a1af77d9ba48f57d76c9dbad0abfb47871d781f65

See more details on using hashes here.

File details

Details for the file snick-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: snick-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for snick-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd0803c1456d28ca6d0ee52b19da4512be614185560e5642a8a987a4d6bfd602
MD5 e63072caf012083bcb94dc9bb526a3a0
BLAKE2b-256 4253a2025737b756fe8d33651ee5a2fd4845163e09dbc052908416c64b8c8dc9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page