Skip to main content

diffstrings

Test Publish to PyPI Publish to TestPyPI PyPi Version Supported Python versions License Code style: black Imports: isort

Show difference of strings in color. It works on both terminal and ipython.

It extends difflib.SequenceMatcher class and provides a direct function too.

Installation

pip install diffstrings

API

Example Result

Colored diff strings

Color explanation:

  • Green: to add
  • Yellow: to replace. (Remove yellow colored then add with green colored strings)
  • Red: to be removed

Example texts

# Truth text to compare with
truth = """Lorem ipsum dolor sit amet,consectetur adipiscing elit,  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.f"""

# Supposedly wrong text to compare
predict = """Lorem furio dlfgor sit amet, consectetur apiscbgfing elit, sed do eiusmod tempor inciddfbunt ut labore et ddslore magna aliqua. Ut enim ad minim veniam, quis nostrud exercsfsation ullamco laboris assi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in volbcvbte velit esse cilldm doldsre eu fugiat nulla pafdgatur. Excepteur sint occaecat cupidatat non pident, sunt in culpa qui asafficia desert mollit anim id est lfdgarum."""

Using class

from diffstrings import SequenceMatcher

s = SequenceMatcher(None, predict, truth, autojunk=False)
print(s.diff_strings())
print(s.diff_strings(True))

Using function

from diffstrings import diff_strings

print(diff_strings(predict, truth))
print(diff_strings(predict, truth, show_change_on_seq2=True))

Metadata

Release files for diffstrings 0.1.3

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

Source distribution (sdist)

Source distribution for diffstrings 0.1.3
File Size Uploaded Provenance
diffstrings-0.1.3.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 11.3 kB

Release files / diffstrings-0.1.3.tar.gz

Download URL diffstrings-0.1.3.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
33245cb445e1a601dbcd3258a1703bfc02650875e9e3b591969cbc8717ac57fc
BLAKE2b-256 checksum
How to use checksums
15b0be128f45a5e27aba4883c469dd033859f152eb0f3f3ace573ba2f08c3b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / diffstrings-0.1.3-py3-none-any.whl

Download URL diffstrings-0.1.3-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c843301b745fe37411e865033be7ff89d221d276d7637fd0674440415254a588
BLAKE2b-256 checksum
How to use checksums
d5b230c58ac9ec895a8a794a86a05295075cbcf3604fc2aa1efd72450aa81238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Security for diffstrings 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

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