Skip to content

Instantly share code, notes, and snippets.

View alvaro-diaz-valenzuela's full-sized avatar
👨‍🏭
Working from home and Bank

Alvaro Diaz Valenzuela alvaro-diaz-valenzuela

👨‍🏭
Working from home and Bank
  • Banco Internacional
  • Chile
  • 16:10 (UTC -04:00)
View GitHub Profile
@alvaro-diaz-valenzuela
alvaro-diaz-valenzuela / capturing.py
Last active June 22, 2020 17:03
Permite capturar el output de consola a un str.
# Taken from a stackoverflow answer ... not written by me.
from io import StringIO
import sys
class Capturing(list):
def __enter__(self):
self._stdout = sys.stdout
sys.stdout = self._stringio = StringIO()
return self
def __exit__(self, *args):