Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Powerstring :zap::knot:

WARNING

Keep in mind that the documentation of this module is not finished yet. The same counts for the module itself. Avoid using the beta version!


The Powerstring module provides many features for working with strings.

Working with multiline strings in python can be very frustating. There's an option by using backslash n and spaces which can be very confusing for reading. Another option is creating multiline strings with three quotes. The problem with that option is, that you have problems with the indention and the code will look ugly. This module provides a feature where you can create multiline strings without destroying the overall look of the code. You can also style parts of the text, insert horizontal rules, create lists and add comments in the text itself.

This module also provides following features:

  • swapping substrings within a string
  • replacing substrings within a string
  • progress counter/bar
  • highlighted strings
  • ansi sequences

Contents

  1. Install the powerstring module
  2. The Powerstring class
    • Setting up a powerstring
    • Style text
    • Adding text to a powerstring
    • Remove ansi from a powerstring
    • Guidelines for setting a title and description

Install the powerstring module

pip install powerstring

Import the powerstring module:

import powerstring as ps

when only using the powerstring class

from powerstring import Powerstring

The Powerstring class

Setting up a powerstring

setup = Powerstring("""Setup -- General information for the setup
    username :: John Doe
    password :: pa0-@kB95$v-Z/~Ky
    email :: john.doe@email.com
""")
print(setup)
print()
print(setup.title)
print(setup.description)

Output:

username :: John Doe
password :: pa0-@kB95$v-Z/~Ky
email :: john.doe@email.com

Setup
General information for the setup

Notice that the print function automatically turns the arguments to string. If you want the powerstring in string format use the str() function.

print(type(setup))
print(type(str(setup)))

Output:

<class 'powerstring.Powerstring'>
<class 'str'>

Style text

The default syntax the Powerstring class uses is powerstring.Syntax.Default. You can use a different syntax by editing the syntax argument.

All syntaxes and their function can be looked up here.

Let's take a look at a few basic functions from the default syntax:

Titles

setup = ps.Powerstring("""
    [ Setup ]
    [username](u) :: [John Doe]i
    [password](u) :: [pa0-@kB95$v-Z/~Ky]i
    [email](u)    :: [john.doe@email.com]i

Keep in mind that the output won't be shown correctly in markdown. Check out the docs or copypaste the code.

Metadata

Release files for powerstring 0.0.1b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for powerstring 0.0.1b1
File Interpreter ABI Platform
powerstring-0.0.1b1-py3-none-any.whl Python 3 none any Details

Release files / powerstring-0.0.1b1-py3-none-any.whl

Download URL powerstring-0.0.1b1-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa364dde45711a16df0a9acd46f344128c93fb9cc605f313ba165df4d2fb1518
BLAKE2b-256 checksum
How to use checksums
4f3fc6890e51d6976d7167b25ad410387eac24ec19d678c41630ffdfa9c486b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.1b1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page