A simple string builder
Project description
A simple string builder
sample
from strbuilder import Builder, SurroundBuilder
condition = False
print(
Builder('base', separator='\n')
.write('header')
.write(Builder(separator=', ')
.write('aaa')
.write_if(condition, 'bbb')
.write_if(condition, 'ccc', or_else='ddd'))
.write(SurroundBuilder(surround='{}')
.write('surrounded!'))
.write('footer')
.build()
)
output
base
header
aaa, ddd
{surrounded!}
footer
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
strbuilder-1.1.3.tar.gz
(2.7 kB
view hashes)