Skip to main content

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)

Uploaded Source

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

Hashes for strbuilder-1.1.3.tar.gz
Algorithm Hash digest
SHA256 dcfa350436baaa11171e54423ff0bf027964e4bfc4c77dadb0ccc58eb432385f
MD5 2eb0b8555642e09945df5bbbf8031fa8
BLAKE2b-256 01f5c55949b37430b34249c47958971f0b5cb8a814d67fd2c5154efce2014ebd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page