Skip to main content

namedtuple from dict / valid identifier from string

# Tested with:
# Python 3.9.13
# Windows 10

pip install namedtuple-from-dict

from namedtuple_from_dict import create_valid_identifier, dict_to_namedtuple

from string import printable
from random import choices, randrange

# startwith will be added if the original string starts with a number
# 9times6 -> aa_9times6

testdict = {
    1: "hallo",
    "n k q": 223,
    (1, 2, 4): {222, 333},
    "validkey1": "test",
    "validkey2": "tes1t",
    "notvalidkey!1": "tes1t",
}

testtuple = dict_to_namedtuple(dic=testdict, name="testdata", startwith="aa_")

print(testtuple)
for i in range(10):
    randomchars = "".join(choices(printable, k=randrange(3, 10)))
    varname = create_valid_identifier(randomchars, startwith="aa_")
    print(f"{randomchars=}")
    print(f"{varname=}")


# testdata(aa_1='hallo', n_k_q=223, aa_1_2_4={333, 222}, validkey1='test', validkey2='tes1t', notvalidkey_1='tes1t')
# randomchars=':ga(F'
# varname='ga_F'
# randomchars='lh[)iN>A/'
# varname='lh_iN_A'
# randomchars='fI&mE)'
# varname='fI_mE'
# randomchars='//YW'
# varname='YW'
# randomchars='aY\x0c'
# varname='aY'
# randomchars='k|\ts \x0b'
# varname='k_s'
# randomchars='!kGhJ`'
# varname='kGhJ'
# randomchars='8u*s'
# varname='aa_8u_s'
# randomchars='\\z;_cP'
# varname='z__cP'
# randomchars='e)=Qb\t7p'
# varname='e_Qb_7p'

	

Metadata

Release files for namedtuple-from-dict 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for namedtuple-from-dict 0.10
File Size Uploaded Provenance Actions
namedtuple_from_dict-0.10.tar.gz 3.8 kB Without provenance Details for namedtuple_from_dict-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for namedtuple-from-dict 0.10
File Interpreter ABI Platform Actions
namedtuple_from_dict-0.10-py3-none-any.whl Python 3 none any Details for namedtuple_from_dict-0.10-py3-none-any.whl

Total release size: 9.2 kB

Release files / namedtuple_from_dict-0.10.tar.gz

Download URL namedtuple_from_dict-0.10.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cfa3c0073e7ef58786df4692b829d12ac9f459b2eeb7bcd9600c90c592cf064d
BLAKE2b-256 checksum
How to use checksums
17f16420f251666fb7a7ea74fb66acb7065191b9f49aec9afa05f0066e9c96a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / namedtuple_from_dict-0.10-py3-none-any.whl

Download URL namedtuple_from_dict-0.10-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fc67e685acddae8d2533a93e6652cfb82f4428b58e95c8b1edff373bc73724c
BLAKE2b-256 checksum
How to use checksums
146c8960080071e75fac40f8327b5f93d025bf109db8b01fd6378b80611e7bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for namedtuple-from-dict 0.10

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.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page