The utils.py
module#
Summary#
Indent each line of a given text. |
Description#
Provides functions for argument filtering and text indenting.
Module detail#
- utils.indent(text: Any, subsequent_indent: str = '', initial_indent: str | None = None) str #
Indent each line of a given text.
- Parameters:
text (Any) – The input text to be indented. If it is not already a string, it will be converted to one.
subsequent_indent (str, optional) – The string to prefix all lines of the text after the first line. Default is an empty string.
initial_indent (Optional[str], optional) – The string to prefix the first line of the text. If not provided, subsequent_indent will be used.
- Returns:
The indented text with specified prefixes applied to each line.
- Return type:
str
Examples
>>> text = "Hello\\nWorld" >>> print(indent(text, subsequent_indent=" ", initial_indent="--> ")) --> Hello World