PyID
Turn any python object into an exactly equivalent object with an id attribute.
Example
import random
import pyid
mylist = [random.sample(range(10), k=3) for i in range(20)]
# Uses python uuid module to assign ID by default
mylist = [pyid.idfy(item) for item in mylist]
for item in mylist:
print(item, item.id)
# Assign a custom ID
mylist = [pyid.idfy(item, 'myid') for item in mylist]
for item in mylist:
print(item, item.id)
Installation
pip install pyid
Motivation
When referencing related objects, we use unique IDs. In python, we might handle this pattern with a dictionary mapping IDs to objects, or use an item's position in a list as its ID. Either case requires we create variables separate from the object to represent those IDs, and that each time we iterate we explicitly include the ID by iterating with the ID dict or the enumerate function for lists. I built this to test the idea that having an ID attribute is easier and cleaner.
How it works
It takes the type of the passed object, creates a subclass of that type, with an ID attribute, and copies the data from the passed object into an instance that new subclass. If a custom ID is not passed, the python uuid module is used to assign one.
Metadata
Release files for pyid 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyid-0.0.3.tar.gz | 2.0 kB | Without provenance | Details for pyid-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyid-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pyid-0.0.3-py3-none-any.whl |
Total release size: 4.2 kB
Release files / pyid-0.0.3.tar.gz
| Download URL | pyid-0.0.3.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91846651d747a8759cea474bc21764a318a4743a6fec32807a6d510f7cbd7cd5
|
|
BLAKE2b-256 checksum How to use checksums |
f56bb44d784600a75ff916bad5af7c528673135b0e02af1e4b71a83ee5a67438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.6
|
Release files / pyid-0.0.3-py3-none-any.whl
| Download URL | pyid-0.0.3-py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
77a233f363ff81ae80ba113396b6c28dca1fb8cd2ccabcb87b1e052575a10e41
|
|
BLAKE2b-256 checksum How to use checksums |
310dab8f774b0570d0b07361e50c89e04589bce20661b8ac9680decbe68a3545
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.6
|
Security for pyid 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.