Skip to main content

pycprint Library Documentation

Introduction

pycprint is a Python library designed to enhance terminal output with customizable text styling, timestamping, colorization, and file redirection capabilities. This document provides an in-depth guide to understanding and using all functionalities offered by the pycprint library.

Installation

Install pycprint via pip, Python's package installer:

pip install pycprint

Usage

Import and use the cprint function from pycprint to enhance your terminal output:

from pycprint import pycprint

cprint = pycprint.pycprint

cprint("Hello, World!")

Features Overview

1. Text Styling

Enhance your messages with various text styles:

  • bold
  • underline
  • italic
  • inverse
  • strikethrough

Example:

cprint("Important message", style='bold')
cprint("Highlighted text", style='underline')

2. Timestamping

Prefix messages with a timestamp in the format [YYYY-MM-DD HH:MM:SS]:

cprint("Event occurred", timestamp=True)

3. Custom Prefix

Prefix messages with a custom string for clarity:

cprint("Error", prefix="ERROR")

4. Text and Background Color

Customize text and background colors using predefined color names:

  • Text colors: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE
  • Background colors: Same options as text colors

Example:

cprint("Success", color='GREEN')
cprint("Highlighted", bg='YELLOW')

5. File Output

Redirect output to a specified file:

cprint("Logged message", file='logfile.txt')

6. Cursor Control

Toggle cursor visibility during printing:

cprint("Loading...", cursor='false')

7. Advanced Features

  • Combining Features: Combine multiple features together for complex output requirements.

    cprint("Critical error occurred!", style='bold', timestamp=True, prefix="ERROR", color='RED')
    

Examples

Here are additional examples demonstrating various combinations of features:

Example 1: Styled and Timestamped Message

cprint("Critical error occurred!", style='bold', timestamp=True)

Output:

[2024-06-13 15:30:00] Critical error occurred!

Example 2: Colored Output with Custom Prefix

cprint("Operation successful", prefix="STATUS", color='GREEN', bg='BLACK')

Output (colored depending on your terminal):

STATUS: Operation successful

Example 3: Redirecting Output to a File

cprint("Debug information", file='debug.log')

Output: (written to debug.log file)

Example 4: Hiding Cursor During Loading

cprint("Loading...", cursor='false')

Output:

Loading... (cursor hidden)

Notes

  • Ensure colorama is installed (pip install colorama) for ANSI color code support.
  • The library gracefully handles errors, printing messages for invalid parameters while continuing with the print operation.

Metadata

Release files for pycprint 1.1.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 pycprint 1.1.0
File Size Uploaded
pycprint-1.1.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycprint 1.1.0
File Interpreter ABI Platform
pycprint-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / pycprint-1.1.0.tar.gz

Download URL pycprint-1.1.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d2ee2e778ff2e205b7ff0ad77ea4df33fe3d6db061068df5a6c1891f0e8e34fb
BLAKE2b-256 checksum
How to use checksums
cf5e4d37237b0e78bf6ae62db77251274463eea7c2f6162dd1ef7dfafd079597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pycprint-1.1.0-py3-none-any.whl

Download URL pycprint-1.1.0-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75fb1d181355b33d070bcf3362c63098fcb3e9487323a5850e514055a49b2e7f
BLAKE2b-256 checksum
How to use checksums
1517323da63dc4d1108df0b259121b4d82412aa2261fa2d403f64c0f030e9459
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.50

2 release files

1.0.10

2 release files

1.0.0

2 release files

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