Skip to main content

Enhanced print() with decorators, formatting, and style patterns

Project description

PyRePrint

Enhanced print() with decorators, formatting, and style patterns.

Installation

pip install pyreprint

Quick Start

from pyreprint import reprint

# Standard print behavior
reprint("Hello, World!")

# With decorators
reprint("Section Title", before="=", after="=", width=40)
# ========================================
# Section Title
# ========================================

# Using styles
reprint("Important!", style="banner", width=40)
# ****************************************
# *             Important!               *
# ****************************************

Decorator Functions

from pyreprint import line, header, box, banner

print(line("=", 40))        # ========================================
print(header("Title"))      # Title\n=====
print(box("Content"))       # +-------+\n| Content |\n+-------+
print(banner("WELCOME", width=40))

Built-in Styles

from pyreprint import reprint

reprint("Text", style="section")   # Lines above and below
reprint("Text", style="header")    # Underlined
reprint("Text", style="box")       # In a box
reprint("Text", style="banner")    # Centered banner
reprint("Text", style="success")   # [OK] Text
reprint("Text", style="warning")   # !! WARNING !! Text
reprint("Text", style="error")     # [ERROR] Text

Custom Styles

from pyreprint import register_style, reprint

@register_style("custom")
def custom_style(text, **kwargs):
    return f">>> {text} <<<"

reprint("Hello", style="custom")  # >>> Hello <<<

Output Capture

from pyreprint import capture_output

with capture_output() as captured:
    print("This is captured")

print(captured.stdout)  # "This is captured\n"

Rich Integration

from pyreprint import rprint, panel, rule

rprint("[bold red]Error:[/bold red] Something went wrong")
rule("Section")
panel("Important", title="Notice")

Sklearn-style Repr

from pyreprint import ReprMixin

class MyModel(ReprMixin):
    def __init__(self, alpha=1.0, max_iter=100):
        self.alpha = alpha
        self.max_iter = max_iter

model = MyModel(alpha=0.5)
print(model)  # MyModel(alpha=0.5, max_iter=100)

Documentation

Full documentation: https://colinconwell.github.io/PyRePrint

License

GPL-3.0-or-later

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

pyreprint-0.1.0.tar.gz (52.8 kB view details)

Uploaded Source

Built Distribution

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

pyreprint-0.1.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file pyreprint-0.1.0.tar.gz.

File metadata

  • Download URL: pyreprint-0.1.0.tar.gz
  • Upload date:
  • Size: 52.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pyreprint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3db565726d3938a26469029771aba1047ce85c177cd6d9e6155b2d0f7df04f1
MD5 0969a886fac26cf9a68daa09a881c989
BLAKE2b-256 4f7b7446e226a86e0d6821d6c0de3d70966a30a792b0ed514b38648244418bdd

See more details on using hashes here.

File details

Details for the file pyreprint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyreprint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pyreprint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f616e97767a64822e20bc34b419203e59ae3242b2d2e5123e2e28ffb1433e637
MD5 8ca7104b1adbd1acf3d7d3d0edee2fb8
BLAKE2b-256 b8c5a583b296133e12c25addba8e93b6c93cb48b1e81789758a962e40e4866bd

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