Skip to main content

SectiPrint

A custom terminal printing library, making printing prettier. Tries to make tracing which function/object did what easier.


Installation

Install using Pip:

pip install sectiprint

Usage

Basic Printing

To use the sectiprint library, you need to first create a RootPrinter() instance:

import sectiprint

#"name" is arbitrary
#"level" is the minimum level to print
say = sectiprint.RootPrinter(name="main", level=printer.DEBUG)

Once you have a printer instance, you will have access to the default print levels:

  • debug [level=0]
  • info [level=10]
  • warning [level=20]
  • error [level=30]

Each print level has a unique colour. To add your own print level, see Advanced: Adding Custom Print Layers

Now you can call each print layer as required:

say.debug("This is a debug statement")
say("This is the default layer, which is 'info'")

Notice how you can directly call the Printer object? This is because when it's called it passes the message to the default print layer, which is "info".

The default layer can be changed by pointing Printer.default to another print layer:

#This does not affect the print level
say.default = say.error

say("This will print as an error!")

Printing In Other Scopes

The power of this lib comes from how printing inside other scopes works. If you wrap a function or class method with @sectiprint.SubLayer it will add a header to the output that shows the path that was takes to get to the current scope:

import sectiprint

@sectiprint.SubLayer
def funcScope():
	say("This is in another scope!")

say = sectiprint.RootPrinter(name="scopes", level=sectiprint.INFO)

say("This is in the top scope!")
funcScope()

This outputs:

Scope example output


Advanced:

Below are some advanced use cases of the Printer lib

Adding Custom Print Layers

There can be cases where you'll want to add your own print layers. This can be easily done by creating a new PrintLevel object and assigning it to a new attribute in the Root Printer object. You would then call this attribute similar to Printer.info and other calls:

import sectiprint

say = sectiprint.RootPrinter("main", level=5)
say.ok = sectiprint.PrintLayer(
	printer = say,
	level = 5,
	colour = print.GREEN
)

say.ok("This is our new print layer!")

In this case, we create the layer "ok" which prints text as green on layer 5. The GREEN var already exists in the sectiprint library, but you can use ANSI Escape Codes to generate your own colours or designs. For example, pass the string '\033[95m' as the colour to produce purple output!

Sections:

You can add "sections" which prints an additional metadata-like label to help clarify where in the code you are. This is useful when you want to separate your code by logical sections, but don't want them as separate functions

import sectiprint
say = sectiprint.RootPrinter("main")

say("Root print")

say.section("New Section")
say("In the new section")

This produces the following output: Section example output

Metadata

Release files for sectiprint 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

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

Release files / sectiprint-2.0.1-py3-none-any.whl

Download URL sectiprint-2.0.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8011bc3e2c9e29d7e00462d45ccd9ebd62733f52b0835b5d884faa7c29b38a4
BLAKE2b-256 checksum
How to use checksums
f742c33ea19e67bb4dea96af500310b5e08a81b334be8cbca025ac5dcfce078a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for sectiprint 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.1 This release

1 release file No provenance

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