Skip to main content

Package to provide a decorator to create singletons

Project description

typed_singleton

A simple Python decorator library for creating singletons.

Installation

pip install typed_singleton

Usage

from typed_singleton import Singleton


@Singleton
class SingletonClass:
    def __init__(self, my_value: int) -> None:
        self.my_value = my_value

    def get_my_awesome_value(self) -> int:
        return self.my_value

instance_1 = SingletonClass(1)
instance_2 = SingletonClass(2)
print(instance_1 is instance_2)  # True

print(instance_1.get_my_awesome_value())  # 1
print(instance_2.get_my_awesome_value())  # also 1

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

typed_singleton-0.1.2.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

typed_singleton-0.1.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file typed_singleton-0.1.2.tar.gz.

File metadata

  • Download URL: typed_singleton-0.1.2.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for typed_singleton-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ea0f53f718a5be5d8a3de97da4f0536521edb5e37af3d60f5b5c12e575a184c6
MD5 7b57ce90cf0358111f1b6eb497ae0fcc
BLAKE2b-256 adff20b1da69da24317b67b9e90c064aaf3a0c47ac942d98db0a5e90ab458f91

See more details on using hashes here.

File details

Details for the file typed_singleton-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: typed_singleton-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for typed_singleton-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4ac8c64f8cadcd5e091e6f9c0d2ec6468c5dee31cb868af95d0dd4f49a6a9e5f
MD5 2eccee2f7ec880ac624afc2a0a6a8e83
BLAKE2b-256 7daa4582791c4b4c25bff0555810d38acb1e6e298c714d7eb73d8fbc39695f81

See more details on using hashes here.

Supported by

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