Skip to main content

A simple Python package to create singleton objects

Project description

Singleton Package

The singleton_package is a simple Python package that provides a Singleton metaclass. This metaclass can be used to create singleton objects, ensuring that only one instance of a class exists throughout the application.

Installation

You can install the singleton_package using pip:

pip install singleton_package

Usage

To use the Singleton metaclass in your classes, simply specify Singleton as the metaclass:

from singleton import Singleton

class MyClass(metaclass=Singleton):
    def __init__(self):
        # Your initialization code here
        pass

# Usage
instance1 = MyClass()
instance2 = MyClass()

# instance1 and instance2 will be the same object
assert instance1 is instance2

Contributing

Contributions are welcome! Please feel free to submit pull requests or report any issues you encounter.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

singleton_package-0.6.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

singleton_package-0.6.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file singleton_package-0.6.0.tar.gz.

File metadata

  • Download URL: singleton_package-0.6.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for singleton_package-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7fa7e974e591319d29d5aa14c383cd835538cc823213db2e3a52e8a51fa68e8b
MD5 09d42a49012a9190fd9b34679adcef76
BLAKE2b-256 bf76fbb68e2d0c3ff80b07976afd6cd67445298189aa10bc97ad90adc8ce7789

See more details on using hashes here.

File details

Details for the file singleton_package-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for singleton_package-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91541c94f3b9ceabbfb2e481a061ef5f2b7d450a1965151c34de0de3c68a9f96
MD5 31fa96b0ea8863aace3bbb5227febd10
BLAKE2b-256 8e39951addfae926e874a3d33f5815bffcc0dd4f0531a974d553140275376c5f

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