Bleach
Remove unsightly visible characters from your code. Inspired by the Acme::Bleach Perl module by Damian
Conway.
Installation
You can install Bleach via pip from PyPI:
$ pip install acme-bleach
Usage
Let's start with the following Python script, hello.py:
print("Hello, world!")
Bleaching
To bleach it, run the following command:
$ bleach bleach hello.py -o hello-bleached.py
The result is a bleached version of the original script. The contents of
hello-bleached.py are (representing tabs with »»»» and spaces with ·):
# coding=bleach
»»»»···»»»»»»»»»»»»»»»»»···»»»»»·»»»»»»»··»»·»»»»»»»·»»»··»»···»»»»»···»·»»»»»»»
»»»»»»»»·»»»·»»»»»»»»»»»»»»»»»»»·»»»»»»»»»»»·»»»»»»»·»»»»»»»·»»»»»»»»»»»»»»»··»»»»»»·»»»·»»»··»»··»»»»»»
»»»»··»»··»»»»»»»»»»··»»····»»»»»»»»·»»»··»»»»»»»»»»»»»»·»»»»»»»»»»»»»»»»»»»»»»»···»···
»»»»··»»····»»»»···»»»»»·»»»»»»»··»»··»»»»»»»»»»··»»»»»»·»»»»»»»»»»»»»»»·»»»»»»»»»»»»»»»·
»»»»»»»»·»»»»»»»»»»»·»»»»»»»»»»»·»»»·»»»»»»»·»»»»»»»»»»»»»»»·»»»·»»»
Running
You can run the bleached file using bleach run:
$ bleach run hello-bleached.py
Hello, world!
Unbleaching
You can unbleach the file using bleach unbleach:
$ bleach unbleach hello-bleached.py -o hello-unbleached.py
$ cat hello-unbleached.py
print("Hello, world!")
Installing the bleach codec
Running scripts with bleach run is far too much effort. If you want to run bleached scripts directly, you can install
the bleach codec:
$ bleach install
Wrote /home/stefans/bleach/.venv/lib/python3.10/site-packages/bleach.pth
$ python hello-bleached.py
Hello, world!
Installing the codec will attempt to write a .pth file to the site-packages directory of the current Python
interpreter. Note the import in the .pth file will be evaluated every time the current Python runs, so there is a
tiny amount of overhead.
License
Distributed under the terms of the MIT license, Bleach is free and open source software.
Credits
This project was generated from a variant of @cjolowicz's Hypermodern Python Cookiecutter template.
Metadata
Release files for acme-bleach 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| acme_bleach-0.2.3.tar.gz | 6.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| acme_bleach-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.6 kB
Release files / acme_bleach-0.2.3.tar.gz
| Download URL | acme_bleach-0.2.3.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea6ce6f8cdad35242f26ce62c457eeae4e062d3bbc541d7c1d5a6c78eda90166
|
|
BLAKE2b-256 checksum How to use checksums |
be16a998081c3c7063207c35efc622e2632567816c4496e1d6461ed7d8528711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / acme_bleach-0.2.3-py3-none-any.whl
| Download URL | acme_bleach-0.2.3-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc3e499b2081db49d5919a4cf5db87885fc4f1568c7d92eb3764a7f2c85aff07
|
|
BLAKE2b-256 checksum How to use checksums |
ce4fa6f875fddc33be98c076f77ad8f5244808b18466181891fc595d8b4ac890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for acme-bleach 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.