Skip to main content

Find common prefix of strings, tuples, and nested structures

Project description

k3pattern

Action-CI Documentation Status Package

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k3pattern-0.1.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k3pattern-0.1.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file k3pattern-0.1.4.tar.gz.

File metadata

  • Download URL: k3pattern-0.1.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3pattern-0.1.4.tar.gz
Algorithm Hash digest
SHA256 da0311de184ff788bb78e3b291f6ce1511ec0ce027ae538fe3d8c59d4b544ef2
MD5 2565c0c6dfaa21cbd108d4283bcbc8db
BLAKE2b-256 4c09013acbb7a36e9bf0231a0ad285f65557bd930ebe9b58354351032ba1ac5e

See more details on using hashes here.

File details

Details for the file k3pattern-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: k3pattern-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3pattern-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 84a467ac3f12b321846c9f5b6dc39c3ce416bee1e958b973f6f2b586bfd8f13b
MD5 e18430de26866fee40bf2e3cb0c416e9
BLAKE2b-256 ea341138fcdc78ad6160ee9d6bf2896a839a2dd1ed287e75d004c8a98583aec3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page