Paper Office
paper-docxAPI referenceshared

TextAccumulator

paper-docx 0.2.0 API reference

Accepts str fragments and joins them together, in order, on `.pop().

Handy when text in a stream is broken up arbitrarily and you want to join it back together within certain bounds. The optional separator argument determines how the text fragments are punctuated, defaulting to the empty string.

TextAccumulator(separator: str = '')

Functions

pop

funcpop() -> Iterator[str]

Generate sero-or-one str from those accumulated.

Using yield from accum.pop() in a generator setting avoids producing an empty string when no text is in the accumulator.

Returns

typing.Iterator[str]

push

funcpush(text: str) -> None

Add a text fragment to the accumulator.

paramtextstr

Returns

None

On this page