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.0.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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for py_default-1.0.0.tar.gz
Algorithm Hash digest
SHA256 927ef6c40501da0ab34056a86eaa4b0dc271bbdf2b3c8ba63e7df323f0aff29b
MD5 e88f3170fcbcb92099885e3350034a89
BLAKE2b-256 f79b4548e2f446c777f075e1584cb4e3b6d3b38befc19327078a2b38651dde50

See more details on using hashes here.

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

Hashes for py_default-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4779aa9496eed266ea052460edb389838cafd13fae014142ca128114b3f65d4f
MD5 f7e312a6f0f61bfb1c542c562d56ad6f
BLAKE2b-256 9270a91058ada37058997b38a0f09692c6885298c4dfa434854a9ca62cf7394a

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