Fancy Pythonic String Builder
- 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 }"