Skip to main content

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_default-1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_default-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file py_default-1.0.1.tar.gz.

File metadata

  • Download URL: py_default-1.0.1.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

Hashes for py_default-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a6d707d9ed25070167e11348d0c99a635f5e7a22bb9f354c929a0b26b2de66ae
MD5 027c8d4998dab8bf4837d36f017d0321
BLAKE2b-256 669b7084dd81269a279739605cea1e565cf0449c42ccc2b787a245bbfc6f70ea

See more details on using hashes here.

File details

Details for the file py_default-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_default-1.0.1-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

Hashes for py_default-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f3f8867109f98b0e873de66f37f7be025fc2c486010b732c7b8f7745a3cc8a2
MD5 dfe92412ae9589d8fd4655f35aa391e9
BLAKE2b-256 2fc067eb6995ca6df368579c48975fbb5bd12555511d82f8c13ded299e34f431

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page