Easy stream redirection in Python.
Project description
Description
This project provides Python context managers to help redirect multiple forms of output into a buffer (capturing the output).
Installation
$ pip install redirect-streams
Basic Usage
The most common use of this project is to redirect stdout.
from io import BytesIO, SEEK_SET, TextIOWrapper
from sys import stdout
from redirect_streams import redirect_stdout
with TextIOWrapper(BytesIO(), stdout.encoding) as buffer:
with redirect_stdout(buffer):
print('this will be saved in the buffer')
buffer.seek(SEEK_SET)
saved = buffer.read()
print(saved)
For other context managers and more detailed information, please refer to the documentation.
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 Distributions
Built Distribution
Close
Hashes for redirect-streams-0.0.1.dev20150819180421.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03e47c3451c8f5825d45b06685e776397317b34a7f33acec3fd4aa220b0c52a3 |
|
MD5 | 531226af4b7893fb5aed34066855e6f1 |
|
BLAKE2b-256 | bdb6a42a5cc21f9f20378f7a50d2aaf771fd86cebebf178b46524b1facb79cd1 |
Close
Hashes for redirect-streams-0.0.1.dev20150819180421.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93c90c15b233fa8e6d0bfe73197de623457963447365f74bb5c37e445fae5f7f |
|
MD5 | 775cb0940d0aebdfd3b9ed693ec608fc |
|
BLAKE2b-256 | c178e850461e893e412360658276d6feffa186a880f6cd828c43d46fce0198ef |
Close
Hashes for redirect_streams-0.0.1.dev20150819180421-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10387364f33dab10e029436c02624981d980ec958d72adfb793f1644ba492a1e |
|
MD5 | 8fc8376485b5b5007ef1ee8012b6c9f9 |
|
BLAKE2b-256 | 9c4d2251f11c0242b2e1262787140b258140a49013578b6b70f2dadabb2b7036 |