Compute the minimal keys for a collection of strings or sequences.
Compute the minimal keys for a collection of strings or sequences. This is intended for use in presenting data in a user interface.
For example, the minimal keys of ["assignments/alice/hw1.txt", "assignments/bob/hw1.txt"] are ["alice", "bob"].
The minimal keys of ["alice/assignments/hw1.txt", "bob/assignments/hw1.txt"] are also ["alice", "bob"].
Finally, the minimal keys of ["assignments/alice.txt", "assignments/bob.txt"] are—wait for it—["alice", "bob"].
This is the same basic idea as a database superkey, except that the actual minimal unique keys are returned, instead of the attributes that select these keys.
The current implementation trims only the beginnings and ends of sequences, because this is all that I’ve needed so far. I have in my head a more sophisticated implementation that uses difflib, but it is too long to fit in the header of this README.
$ pip install minimalkeys
>>> from minimalkeys import minimalkeys >>> minimal_keys(["assignments/alice/hw1.txt", "assignments/bob/hw1.txt"]) ['alice', 'bob']
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size minimalkeys-0.1.0-py3-none-any.whl (5.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size minimalkeys-0.1.0.tar.gz (7.0 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for minimalkeys-0.1.0-py3-none-any.whl