Protected classes.
Project description
Overview
Use the class Protected as a parent.
Installation
To install protectedclasses, you can use pip. Open your terminal and run:
pip install protectedclasses
Implementation
class Protected:
def __setattr__(self, name, value):
cls = type(self)
if name.startswith("_"):
super().__setattr__(name, value)
return
if isinstance(getattr(cls, name, None), property):
super().__setattr__(name, value)
return
e = "%r object has no property %r"
e %= (cls.__name__, name)
raise AttributeError(e)
License
This project is licensed under the MIT License.
Links
Credits
Author: Johannes
Thank you for using protectedclasses!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file protectedclasses-1.0.0.tar.gz
.
File metadata
- Download URL: protectedclasses-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 092288b1f5c394f6395e03117eefdd6a557ffeeb20e8578c39151460a32eaf58 |
|
MD5 | 17d33b03523aa493e352c58826f24b50 |
|
BLAKE2b-256 | e12d333aabb60467f7adab852c9cc9273a7c7f472dca299541cb867d178c049e |
File details
Details for the file protectedclasses-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: protectedclasses-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66a780a41a8a21c38c899197ff31136d7ba65e7fbe862677e49e493d7dd48f6 |
|
MD5 | fb1e9c25f5ffba50ae30bf37c7e301b7 |
|
BLAKE2b-256 | 35ba88275ee5e84776b92a8cf24de1e41e5707e6ed30c0c8da1a6f8166007d3d |