Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msabramo/ansi_str
Experiment with Python str subclass whose __len__ excludes ANSI escapes
https://github.com/msabramo/ansi_str
Last synced: about 1 month ago
JSON representation
Experiment with Python str subclass whose __len__ excludes ANSI escapes
- Host: GitHub
- URL: https://github.com/msabramo/ansi_str
- Owner: msabramo
- License: mit
- Created: 2015-02-27T14:49:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-27T19:51:45.000Z (almost 10 years ago)
- Last Synced: 2024-05-09T20:47:02.774Z (8 months ago)
- Language: Python
- Size: 270 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
ansi_str
========You should just use https://github.com/Robpol86/colorclass
----------------------------------------------------------An experimental Python ``str`` subclass, whose ``__len__`` method excludes ANSI
color escape codesWhen you call the ``__len__`` method, it discounts ANSI color escape codes.
This is beneficial, because ANSI color escape codes won't mess up code that
tries to do alignment, padding, printing in columns/tables, etc... image:: ansi_str_example.png
.. code-block:: python
In [1]: from ansi_str import ansi_str
In [2]: s = ansi_str(u'\x1b[32m\x1b[1mSUCCESS\x1b[0m')
In [3]: len(s)
Out[3]: 7