k3pattern
Find common prefix of several strings, tuples of string, or other nested structure, recursively by default.
k3pattern is a component of pykit3 project: a python3 toolkit set.
Find common prefix of several string, tuples of string, or other nested structure, recursively by default. It returns the shortest prefix: empty string or empty tuple is removed.
Install
pip install k3pattern
Synopsis
import k3pattern
k3pattern.common_prefix('abc', 'abd') # 'ab'
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'abd')) # (1, 2, 'ab')
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'xyz')) # (1, 2); empty prefix of 'abc' and 'xyz' is removed
k3pattern.common_prefix((1, 2, (5, 6)), (1, 2, (5, 7))) # (1, 2, (5,) )
k3pattern.common_prefix('abc', 'abd', 'abe') # 'ab'; common prefix of more than two
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Metadata
Release files for k3pattern 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| k3pattern-0.1.4.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| k3pattern-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / k3pattern-0.1.4.tar.gz
| Download URL | k3pattern-0.1.4.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da0311de184ff788bb78e3b291f6ce1511ec0ce027ae538fe3d8c59d4b544ef2
|
|
BLAKE2b-256 checksum How to use checksums |
4c09013acbb7a36e9bf0231a0ad285f65557bd930ebe9b58354351032ba1ac5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / k3pattern-0.1.4-py3-none-any.whl
| Download URL | k3pattern-0.1.4-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84a467ac3f12b321846c9f5b6dc39c3ce416bee1e958b973f6f2b586bfd8f13b
|
|
BLAKE2b-256 checksum How to use checksums |
ea341138fcdc78ad6160ee9d6bf2896a839a2dd1ed287e75d004c8a98583aec3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|