Skip to main content

This package provides a decorator to make read only attributes on a given Python class

Project description

Read only Python Class Attributes

This package provides a decorator to make read only attributes on a given Python class

Install

pip install read_only_class_attributes

Usage

from read_only_class_attributed import read_only

#example for all read only attributes
@read_only('*')
class _CONSTANTS:
    pi = 3.14159
    G = 6.67430e-11

CONSTANTS = _CONSTANTS()


#example for some read only attributes
@read_only('pi', 'G')
class _PLANETCONSTANTS:
    pi = 3.14159
    G = 6.67430e-11
    g = 9.18 #can change
    planet = 'Earth' #can change

PLANETCONSTANTS = _PLANETCONSTANTS()

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

read_only_class_attributes-1.0.1.tar.gz (18.6 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page