Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Easy stream redirection in Python.

Project Description

Package Documentation


This project provides Python context managers to help redirect multiple forms of output into a buffer (capturing the output).


$ 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 os import system
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')
        # code below won't work with stdlib's redirect_stdout
        system('this will be saved in the buffer')
    saved =

For other context managers and more detailed information, please refer to the documentation.

Release History

This version
History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(4.5 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Aug 20, 2015
(3.3 kB) Copy SHA256 Hash SHA256
Source None Aug 20, 2015
(6.2 kB) Copy SHA256 Hash SHA256
Source None Aug 20, 2015

Supported By

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 Google Google Cloud Servers DreamHost DreamHost Log Hosting