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.5.0.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

singleton_package-0.5.0-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

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