MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / py_print

Method py_print

cmd2/cmd2.py:4880–4901  ·  view source on GitHub ↗

Print objects to a stream, defaulting to self.stdout. This is used as the print() function within interactive Python shells and pyscripts. It wraps cmd2's print_to() method to honor output redirection and style settings. :param objects: objects to print (includi

(
            *objects: Any,
            sep: str = " ",
            end: str = "\n",
            file: IO[str] | None = None,
            flush: bool = False,  # noqa: ARG001
        )

Source from the content-addressed store, hash-verified

4878 # Using self.print_to(self.stdout) ensures output is capturable and respects 'allow_style'
4879 # without requiring the user to have access to 'self'.
4880 def py_print(
4881 *objects: Any,
4882 sep: str = " ",
4883 end: str = "\n",
4884 file: IO[str] | None = None,
4885 flush: bool = False, # noqa: ARG001
4886 ) -> None:
4887 """Print objects to a stream, defaulting to self.stdout.
4888
4889 This is used as the print() function within interactive Python shells and pyscripts.
4890 It wraps cmd2's print_to() method to honor output redirection and style settings.
4891
4892 :param objects: objects to print (including Rich objects)
4893 :param sep: string to write between printed text. Defaults to " ".
4894 :param end: string to write at end of printed text. Defaults to a newline.
4895 :param file: file stream being written to. Defaults to self.stdout.
4896 :param flush: ignored as Rich-based output is flushed automatically. Defaults to False.
4897 """
4898 if file is None:
4899 file = self.stdout
4900
4901 self.print_to(file, *objects, sep=sep, end=end)
4902
4903 # Replace quit/exit in the embedded Python environment. Standard sys.exit()
4904 # would kill the entire application process; raising EmbeddedConsoleExit

Callers

nothing calls this directly

Calls 1

print_toMethod · 0.95

Tested by

no test coverage detected