Skip to main content

Partially lockable strings

Project description

lstr: Lockable Python Strings

lstr is a Python package for partially lockable strings.

Without locks, an lstr can be updated:

from lstr import lstr

greeting = lstr("Hello, world!")
print(greeting)  # "Hello, world!"

greeting.replace("Hey", index=0, length=5)  # True
print(greeting)  # "Hey, world!"

To prevent a part of the string being updated, add a lock:

from lstr import lstr

greeting = lstr("Hello, world!")
greeting.lock(index=0, length=5)

greeting.replace("Hey", index=0, length=5)  # False
print(greeting)  # "Hello, world!"

greeting.replace(" there", index=5, length=7)  # True
print(greeting)  # "Hello there!"

Thank you! 🎉

My name is Cariad, and I'm an independent freelance DevOps engineer.

I'd love to spend more time working on projects like this, but--as a freelancer--my income is sporadic and I need to chase gigs that pay the rent.

If this project has value to you, please consider ☕️ sponsoring me. Sponsorships grant me time to work on your wants rather than someone else's.

Thank you! ❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

lstr-0.0.0a1-py3-none-any.whl (1.8 kB view hashes)

Uploaded Python 3

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