Skip to main content

The Unix command tee splits the output of a program so that it is both displayed on screen and written to a file. The pyteetime package provides such a functionality in Python. It is based on the original code from A. Peck, with a few classmethods added.

Usage:

Run the example script tee-test.py listed here:

from pyteetime import tee
import sys

print('This prologue will appear on screen but not in a logfile')

LOGFILE = tee.stdout_start(append=False) # STDOUT
# from now on, all output is also copied to the logfile

tee.stderr_start(append=False) # STDERR
# from now on, all output to STDERR is also copied to stderr.log

print('This text will appear on screen and also in the logfile')

print('This will appear on screen and also in stderr.log', file=sys.stderr) 

# input from keyboard does not go to logfile:
answer = input('Enter something!\n')

# show the input to make sure it also goes into the logfile:
print('The user typed: %s' % (answer))

# data written to a file is not copied to the logfile:
DATAFILE = open('tee-test.dat','w+')
print(list(range(5)), file=DATAFILE)
DATAFILE.close()

print('This goes to the logfile but will not appear on screen', file=LOGFILE)

tee.stdout_stop()
# from now on, output to STDOUT will not go to stdout.log anymore

tee.stderr_stop()
# from now on, output to STDERR will not go to stderr.log anymore

print('This epilogue will appear on screen but not in a logfile')

Metadata

Release files for pyteetime 1.0.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 pyteetime 1.0.0
File Size Uploaded
pyteetime-1.0.0.tar.gz 2.8 kB Details

Built distribution (wheel)

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

Total release size: 19.5 kB

Release files / pyteetime-1.0.0.tar.gz

Download URL pyteetime-1.0.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e639a08d4f0a87200512f73303b9bea03b9acd016b308cfd65bbdec81c0dbd22
BLAKE2b-256 checksum
How to use checksums
c3da2cbb3c2a255eda9b48382e0265ebd208e07b34f337f71cb8b3d856104842
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.9

Release files / pyteetime-1.0.0-py3-none-any.whl

Download URL pyteetime-1.0.0-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
308fdc096295fff86d74a3501cc431f9fa6220136d3855ad3940ece84fc670fa
BLAKE2b-256 checksum
How to use checksums
8c58b18765217996e587a4dc17bd5e4fb823eb3b7aa9cd71db994e7d28971b5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

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