Miscellaneous Functions

linesep.ascii_splitlines(s: str, keepends: bool = False) list[str][source]

New in version 0.3.0.

Like str.splitlines(), except it only treats "\n", "\r\n", and "\r" as line endings

linesep.read_paragraphs(fp: Iterable[str]) Iterator[str][source]

New in version 0.3.0.

Read a text filehandle or other iterable of lines (with trailing line endings retained) paragraph by paragraph. Each paragraph is terminated by one or more blank lines (i.e., lines containing only a line ending). Trailing and embedded line endings in each paragraph are retained.

Only "\n", "\r\n", and "\r" are recognized as line endings.

linesep.split_paragraphs(s: str) list[str][source]

New in version 0.3.0.

Split a string into paragraphs, each one terminated by one or more blank lines (i.e., lines containing only a line ending). Trailing and embedded line endings in each paragraph are retained.

Only "\n", "\r\n", and "\r" are recognized as line endings.