A simple package to allow for text on the terminal which is overwritten by the next call to print.
Project description
temp_text
usage
from time import sleep
import temp_text
for i in range(100):
if i % 10 == 0:
print(f"Found special number: {i}")
temp_text.prnt(f"Looking at {i}")
sleep(0.3)
from time import sleep
from itertools import *
import temp_text
for c in chain.from_iterable(tee("-\\|/", 10)):
temp_text.prnt(c)
sleep(0.3)
import os
import temp_text
for d, _, _ in os.walk("/"):
temp_text.prnt(d)
description
A simple package to allow for text on the terminal which is overwritten by the next call to print.
prnt
Print a temporary string to the console. Must not contain newline characters, because only the line the cursor is currently on is cleared. This function calls hide if there is a temporary string on the console.
If trim_to_width is True (this is the default), then the string has some characters in the middle replaced with ellipsis so it does not span multiple lines.
hide
Clears the line the cursor is currently on if there is a temporary string there.
Hide is also called if the program exits.
use_write_guards
If this setting is True (this is the default) then calling regular print (or any other function that invokes sys.stdout.write or sys.stderr.write) first clears the current line, assuming there is a temporary string there.
import temp_text
temp_text.use_write_guards = False
temp_text.prnt("Hello, World")
# Output: "Hello, World"
print("Hello, World!")
# Output: "Hello, WorldHello, World!"
# If you inserted a temp_text.hide() before the print,
# then the output would be the expected "Hello, World!"
# use_write_guards = True does this automatically
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file temp_text-2026.2.1.tar.gz.
File metadata
- Download URL: temp_text-2026.2.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70d4481e3b45853c1400855c40a0a865bd1a2f33bc478a59eb12f7f26304fcaf
|
|
| MD5 |
36a20afa2bc47a1c5b6b05baf8f07df6
|
|
| BLAKE2b-256 |
567d90b552b35c87b60529792a06aef143e052052d2aabbdb5527de0aff65e69
|
File details
Details for the file temp_text-2026.2.1-py3-none-any.whl.
File metadata
- Download URL: temp_text-2026.2.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f4a06139fb19e800fd668aed16b581a149d80d9fba1e05a12a4de4dc22af466
|
|
| MD5 |
e793d5ad3bbb420c8afd94ae804d2e8e
|
|
| BLAKE2b-256 |
82a9dcb0bd5446fb4cb43774a380f0cabc3f5b724a3b4e359c632d2a98396707
|