buildstr

Fancy Pythonic String Builder.


License
Other
Install
pip install buildstr==0.1.1

Documentation

Fancy Pythonic String Builder

image

image

Documentation Status

  • Free software: Apache Software License 2.0

Features

  • Builds strings in a pythonic way.
  • We're using the with statement to build substrings.
  • Python code can be interleaved with the string building.

Useful for generating code.

Example

from buildstr import Builder

b = Builder("A")
b << "B"
with b(surround=("{ ", " }"), separator="; ") as b1:
    b1 << ["a", "b", "c"]

assert b.build() == "A B { a; b; c }"