from contextlib import redirect_stdout
import io


def capture_stdout(func, *args, **kwargs):
    """Capture standard output to a string buffer"""


    stdout_string = io.StringIO()
    with redirect_stdout(stdout_string):
        func(*args, **kwargs)
    return stdout_string.getvalue()