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.0.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.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: snick-3.0.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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.0.0.tar.gz
Algorithm Hash digest
SHA256 5141340a50c7e0e08b213df78f6a4770336a36465b22a075ee9afcce408f7793
MD5 d75a405437054eebb3424a799b28923f
BLAKE2b-256 a17c9a7ab0b4900160b02634f98f99a9d25517e1de8cb1ad09605d3def9b62a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: snick-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b391afec7979070f909287c95f68b2df119132ca5839e2f120cdd2dcc0bfabc6
MD5 27e5bd2d7af54f62866dbac15ea37e6f
BLAKE2b-256 fffca08ef34f79573379c2535a1000dd3b05cd586a7a9d3b914e726ae1360873

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