Snake Dict
Keep your dictionary keys PEP 8 compliant
Quick Example
from snakedict import convert
my_dict = {
"helloWorld": "test",
"thisIsCamelCase": "hello",
"this_is_snake_case": "world",
}
my_dict = convert(a)
print(my_dict["hello_world"]) # test
Installation
Linux/macOS
python3 -m pip install -U pointers.py
Windows
py -3 -m pip install -U pointers.py
Usage
There are 2 main functions, convert and auto.
convert does what was shown above, it takes in a dictionary and converts keys that are in camelCase to snake_case:
from snakedict import convert
my_dict = {
"something": "test",
(1, 2, 3): "hello" # you can use any key you want, snakedict won't touch it unless its in camelcase
}
print(convert(my_dict)) # no camelcase found, nothing happens
On the other hand, auto is a decorator that converts the response to snake case:
from snakedict import auto
@auto()
def fetch_something():
return { # lets pretend this is a call to some api
"accountName": "someone1234",
"joinDate": "7/19/22",
}
print(fetch_something()["account_name"])
auto has a parameter called execute_maybe that won't call convert if the response wasn't a dict:
If you want an error to be raised if the function returns None, set it to False:
@auto(execute_maybe = False)
def fetch_something():
return None
fetch_something() # TypeError!
Metadata
Release files for snakedict 1.0.0
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 |
|---|---|---|---|---|
| snakedict-1.0.0.tar.gz | 3.5 kB | Without provenance | Details for snakedict-1.0.0.tar.gz |
Release files / snakedict-1.0.0.tar.gz
| Download URL | snakedict-1.0.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19735b11b912e43736b91385a46c4cc38f670554188c1e103b473d036405498c
|
|
BLAKE2b-256 checksum How to use checksums |
876a6b3072c70cb485f7ca6e225548c2c0973d8d8de742179fb800b979a914db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for snakedict 1.0.0
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.