Find common prefix of several `string`s, tuples of string, or other nested structure, recursively by default.
Project description
k3pattern
Find common prefix of several string
s, 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file k3pattern-0.1.0.tar.gz
.
File metadata
- Download URL: k3pattern-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a8bea6ac6fc2d8cf1518bc0d1977beec9daa8281cc25e4e7e13117f63726f1f |
|
MD5 | 8b321196dee11541b1180f9f1aa86a72 |
|
BLAKE2b-256 | 19fd48b8c6d65e2e64110440f7df6b9a86d9aa27c6d2bbd64a270ba97ae5033d |
File details
Details for the file k3pattern-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: k3pattern-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 379069c5f1cf202c953d2143c2f9774dc6b736daafc0bb9ea061f4a0f8d270a9 |
|
MD5 | c44ee1cf49c48104746f107bb13de4ce |
|
BLAKE2b-256 | 246076766db87b5ba5aee1358635b4a23ca5dfacadc79922f78cce156b9be8a8 |