Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

Easy stream redirection in Python.

Project Description

Package Documentation

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.

Release History

Release History

This version
History Node
Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
redirect_streams-0.0.1.dev20150819180421-py2.py3-none-any.whl (4.5 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Aug 20, 2015
redirect-streams-0.0.1.dev20150819180421.tar.gz (3.2 kB) Copy SHA256 Checksum SHA256 Source Aug 20, 2015
redirect-streams-0.0.1.dev20150819180421.zip (6.2 kB) Copy SHA256 Checksum SHA256 Source Aug 20, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting