Skip to main content

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 -> 0
  • bool -> 0 (False)
  • complex -> complex()
  • str -> ""
  • float -> 0.0
  • list -> []
  • set -> set()
  • dict -> {}
  • anything else -> None

Metadata

Release files for py-default 1.0.1

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

Source distribution (sdist)

Source distribution for py-default 1.0.1
File Size Uploaded Provenance Actions
py_default-1.0.1.tar.gz 2.8 kB Without provenance Details for py_default-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-default 1.0.1
File Interpreter ABI Platform Actions
py_default-1.0.1-py3-none-any.whl Python 3 none any Details for py_default-1.0.1-py3-none-any.whl

Total release size: 6.3 kB

Release files / py_default-1.0.1.tar.gz

Download URL py_default-1.0.1.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a6d707d9ed25070167e11348d0c99a635f5e7a22bb9f354c929a0b26b2de66ae
BLAKE2b-256 checksum
How to use checksums
669b7084dd81269a279739605cea1e565cf0449c42ccc2b787a245bbfc6f70ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Release files / py_default-1.0.1-py3-none-any.whl

Download URL py_default-1.0.1-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f3f8867109f98b0e873de66f37f7be025fc2c486010b732c7b8f7745a3cc8a2
BLAKE2b-256 checksum
How to use checksums
2fc067eb6995ca6df368579c48975fbb5bd12555511d82f8c13ded299e34f431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Security for py-default 1.0.1

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

1.0.1 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