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 details)
File details
Details for the file strbuilder-1.1.3.tar.gz
.
File metadata
- Download URL: strbuilder-1.1.3.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcfa350436baaa11171e54423ff0bf027964e4bfc4c77dadb0ccc58eb432385f |
|
MD5 | 2eb0b8555642e09945df5bbbf8031fa8 |
|
BLAKE2b-256 | 01f5c55949b37430b34249c47958971f0b5cb8a814d67fd2c5154efce2014ebd |