Skip to main content

An enhanced print function supporting color and text styles.

Project description

myprintx 🎨

A lightweight Python library that enhances the built-in print() function.

Features

  • ✅ Colorful output — control both foreground & background colors
  • ✅ Text styles — support bold, italic, and underline
  • ✅ Non-intrusive design — 100% compatible with the built-in print()
  • ✅ Global patch — one-line activation for all print() calls
  • ✅ Auto prefix — show date, time, tag, and location info
  • ✅ Built-in log helpers — info(), warn(), error(), debug()

Install

pip install myprint

🧩 No extra dependencies.

Usage

# 基本用法
import myprintx
myprintx.print("普通输出")
myprintx.print("成功", fg_color="green", style="bold")
myprintx.print("警告", fg_color="yellow", style="underline")
myprintx.print("错误", fg_color="white", bg_color="red")

# 启用彩色全局打印
import myprintx
myprintx.patch_color()
print("绿色输出", fg_color="green", style="bold")
print("错误输出", fg_color="white", bg_color="red")
myprintx.unpatch_color()  # 恢复原始 print()

# 启用前缀打印
import myprintx
## 启用:日期、时间、自定义标签、位置信息
myprintx.patch_prefix(custom_prefix="INFO", show_location=True)
myprintx.print("启动成功", fg_color="green")
myprintx.print("任务执行中", fg_color="cyan")
myprintx.unpatch_prefix()  # 关闭前缀

# 控制是否屏蔽所有 print 输出
myprintx.print("调试输出")  # 正常输出
myprintx.set_show(False)
myprintx.print("生产环境不应出现这行")  # 不输出
myprintx.set_show(True)
myprintx.print("恢复输出")  # 恢复打印

# 简易快速调用
import myprintx
myprintx.patch_prefix(show_location=True)
myprintx.info("系统初始化完成")
myprintx.warn("配置文件缺少部分字段")
myprintx.error("数据库连接失败")
myprintx.debug("缓存刷新完成")
myprintx.unpatch_prefix()

# mode用法
import myprintx
myprintx.print("mode模式调试输出", mode="debug")
myprintx.debug("简易模式调试输出")
myprintx.show_debug(False) # 只屏蔽 debug
myprintx.debug("这行不会输出")
myprintx.print("这行也不会输出", mode="debug")
myprintx.info("这行仍然会输出")
myprintx.show_debug() # 恢复 debug
myprintx.debug("debug 恢复了")
myprintx.set_show(False) # 一键全关
myprintx.error("这行也不会输出")

Pack & Publish

# test
python -m unittest  tests/test_myprintx.py -v

pip install build twine

# update version in setup.py
version="1.0.x"

# update version in myprintx/__init__.py
__version__="1.0.x"

# package myprintx
rm -rf dist/
python -m build

# test install (optional)
pip install dist/myprintx-1.0.x-py3-none-any.whl --force-reinstall

# publish to pypi
twine upload dist/*

# install from pypi
pip install myprintx --upgrade

Blog

TODO

more ...

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

myprintx-1.0.5.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

myprintx-1.0.5-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file myprintx-1.0.5.tar.gz.

File metadata

  • Download URL: myprintx-1.0.5.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for myprintx-1.0.5.tar.gz
Algorithm Hash digest
SHA256 92c73861d4b078d9b01f984bc4b59fecd047eb78ee5f491f4ce0c12c8d2a0554
MD5 a5262e2bd2bd1482b5e532d9613584e6
BLAKE2b-256 cefd4999c37522d96f6c83cd51d4f79a7458685be7f0b20ee1582d2b5ed98ad5

See more details on using hashes here.

File details

Details for the file myprintx-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: myprintx-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for myprintx-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 927899694c85f78f4c3e326299ce1efb82c40769b162a3c82c737abf12d19ee9
MD5 3a99c2b1371de5abbc13e6aaea80b3ff
BLAKE2b-256 4ae4a923a3627ffec64513364b32ffaff33d8f7b28336d674865a5e7dde77745

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