Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

temp_text-2026.1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

temp_text-2026.1.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file temp_text-2026.1.1.tar.gz.

File metadata

  • Download URL: temp_text-2026.1.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

Hashes for temp_text-2026.1.1.tar.gz
Algorithm Hash digest
SHA256 ed70fcbf1bd81b8007538c4891265ddbe8e9fff35e263c0d56d362a776febd1f
MD5 835a286247c1b7626f993763691d4359
BLAKE2b-256 3e6d6b6e0e4662a1cdf823879938ee40881359291f6c642f8e572ac1bad85f0e

See more details on using hashes here.

File details

Details for the file temp_text-2026.1.1-py3-none-any.whl.

File metadata

  • Download URL: temp_text-2026.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for temp_text-2026.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 799bb1c911821bd482d97a830360060eac68313a45ec7277724a382ee5e41006
MD5 68b6bcda522e64b3dcc99e89a2ff41f9
BLAKE2b-256 335cca65591385862353dd09a1742a7f39d2aaf285f59ff15d4f3e2f9569f23d

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