io.base
OutputStream
@runtime_checkable
class OutputStream(Protocol)
print
def print(*objects: Any,
sep: str = " ",
end: str = "\n",
flush: bool = False) -> None
Print data to the output stream.
Arguments:
objectsany - The data to print.sepstr, optional - The separator between objects. Defaults to " ".endstr, optional - The end of the output. Defaults to " ".flushbool, optional - Whether to flush the output. Defaults to False.
InputStream
@runtime_checkable
class InputStream(Protocol)
input
def input(prompt: str = "", *, password: bool = False) -> str
Read a line from the input stream.
Arguments:
promptstr, optional - The prompt to display. Defaults to "".passwordbool, optional - Whether to read a password. Defaults to False.
Returns:
str- The line read from the input stream.
IOStream
@runtime_checkable
class IOStream(InputStream, OutputStream, Protocol)
A protocol for input/output streams.
set_global_default
@staticmethod
def set_global_default(stream: "IOStream") -> None
Set the default input/output stream.
Arguments:
streamIOStream - The input/output stream to set as the default.
get_global_default
@staticmethod
def get_global_default() -> "IOStream"
Get the default input/output stream.
Returns:
IOStream- The default input/output stream.
get_default
@staticmethod
def get_default() -> "IOStream"
Get the default input/output stream.
Returns:
IOStream- The default input/output stream.
set_default
@staticmethod
@contextmanager
def set_default(stream: Optional["IOStream"]) -> Iterator[None]
Set the default input/output stream.
Arguments:
streamIOStream - The input/output stream to set as the default.