lexid is a micro library (version 2021.1006) designed to generate and increment lexically ordered numerical IDs. Its core functionality ensures that `older_id < newer_id` remains true throughout a sequence, whether dealing with integers or strings. This is achieved by special incrementing that uses the leftmost character/digit to maintain lexical order and prevent premature numerical overflow. It's useful for scenarios like build numbers or version strings that are often sorted by tools using simple lexical ordering, such as the UNIX sort command or JavaScript's string comparison. The library maintains an active status with updates as needed.
pip install lexidVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the basic usage of the `lexid.incr()` function. It shows how to increment a string-based ID and highlights the unique lexical ordering mechanism where the leftmost digit can be incremented 'early' to maintain ordering, which can increase the ID's length. It also includes the recommended practice of starting with a higher number to mitigate frequent rollovers.
Understand the library's core principle of lexical ordering as explained in the documentation. Test sequences to observe behavior. Consider the impact on storage or display if ID length changes are an issue.
The documentation recommends starting with a higher number, like '1001', to reduce the frequency of rollovers and avoid potential issues with zero truncation (e.g., if a system processes '0001' as '1').
Run `pip install lexid` in your terminal to install the library.
Use `lexid.incr()` instead of `lexid.increment()`. For example: `new_id = lexid.incr('1001')`.Ensure the input to `lexid.incr()` is a string or integer that represents a valid numerical ID. For example: `new_id = lexid.incr('123')` or `new_id = lexid.incr(123)`.No dependency data recorded yet.