Uniform Default Values for Python
Project description
PyDefault - Uniform Default Values for Python
PyDefault allows for uniform assignment/generation of default values for common types in Python. The API comes in two forms - a function and a map.
Installation
You can install pydefault using pip via pip install py-default, or you may install it using pip using the GitHub repo URL. Distributions are also available from dist/ at the root of the repository.
Function API
from pydefault import default
class Person: ...
mynum = default(int) # initializes to 0
empty_list = default(list) # initializes to []
obj = default(Person) # initializes to None
Map API
from pydefault import default
class Person: ...
mynum = default[int] # initializes to 0
empty_list = default[list] # initializes to []
obj = default[Person] # initializes to None
Default Values
The following types resolve to the following default values:
int->0bool->0(False)complex->complex()str->""float->0.0list->[]set->set()dict->{}- anything else ->
None
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_default-1.0.0.tar.gz.
File metadata
- Download URL: py_default-1.0.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
927ef6c40501da0ab34056a86eaa4b0dc271bbdf2b3c8ba63e7df323f0aff29b
|
|
| MD5 |
e88f3170fcbcb92099885e3350034a89
|
|
| BLAKE2b-256 |
f79b4548e2f446c777f075e1584cb4e3b6d3b38befc19327078a2b38651dde50
|
File details
Details for the file py_default-1.0.0-py3-none-any.whl.
File metadata
- Download URL: py_default-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4779aa9496eed266ea052460edb389838cafd13fae014142ca128114b3f65d4f
|
|
| MD5 |
f7e312a6f0f61bfb1c542c562d56ad6f
|
|
| BLAKE2b-256 |
9270a91058ada37058997b38a0f09692c6885298c4dfa434854a9ca62cf7394a
|