Skip to main content

Find common prefix of strings, tuples, and nested structures

Project description

k3pattern

Action-CI Build Status 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.1.tar.gz (4.6 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.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: k3pattern-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 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.1.tar.gz
Algorithm Hash digest
SHA256 f773e135a1f9ec0b30367d8dc7336800b09957a9966e0a0b8e37fda61be637f3
MD5 814a0896f09902ae8decbebb2800959d
BLAKE2b-256 4a7ee2c320708fd6afe2f1f768bedb9c64ee445cc0af240f8dc1d0b787d8488f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: k3pattern-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6248034bfd5382d0f48d0ef6442ad991488caa644d036ad594766e3fc5131d08
MD5 f2fd9114588bc4e6fbd84e278de50212
BLAKE2b-256 b7b2996c0bb043a872ffbdc91de14f6a031890ad56ffbe6917b10cae03e61247

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