Skip to content

Instantly share code, notes, and snippets.

@Diapolo10
Last active September 7, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Diapolo10/077d6321c0f88d76f9b08c0c3e32da2f to your computer and use it in GitHub Desktop.
Save Diapolo10/077d6321c0f88d76f9b08c0c3e32da2f to your computer and use it in GitHub Desktop.
Python print-function mock-up
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