Last active
September 7, 2020 16:56
-
-
Save Diapolo10/077d6321c0f88d76f9b08c0c3e32da2f to your computer and use it in GitHub Desktop.
Python print-function mock-up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from typing import TextIO | |
def my_print(*args: list, file: TextIO=sys.stdout, sep: str=' ', end: str='\n', flush: bool=False) -> None: | |
""" | |
Prints the values to a stream, or to sys.stdout by default. | |
Optional keyword arguments: | |
file: a file-like object (stream); defaults to the current sys.stdout. | |
sep: string inserted between values, default a space. | |
end: string appended after the last value, default a newline. | |
flush: whether to forcibly flush the stream. | |
""" | |
file.write( | |
sep.join( | |
map(str, args) | |
) + end | |
) | |
if flush: | |
file.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment