https://github.com/user0332/pyprotectionlevel
https://github.com/user0332/pyprotectionlevel
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/user0332/pyprotectionlevel
- Owner: User0332
- License: mit
- Created: 2023-08-15T18:39:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-15T18:40:53.000Z (almost 3 years ago)
- Last Synced: 2025-01-24T06:11:46.107Z (over 1 year ago)
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyProtectionLevel
## Install
Install PyProtectionLevel using `pip` with `pip install protectionlevel`. The package module is named `protectionlevel`, so you can import all decorators with `from protectionlevel import *`.
## Docs & Usage
Access modifier support for Python. Includes the following access modifiers as decorators:
- `@protectiondefault` - uses the default protection for the item (private); if used on a class, then all attributes will be private (unless specified otherwise by an attribute decorator)
- `@public` - exposes the attribute of the class even if the class is decorated with `@protectiondefault`
- `@private` - makes attribute private (only the class can access the attribute)
- `@protected` - only the class and subclasses can access the attribute
- `@readonly` - the attribute cannot be set
- `@exposeset(access_modifier)` - Can pass either `protectionlevel.private` or `protectionlevel.protected` as the argument to this decorator. Allows code that falls under the protection level passed as `access_modifier` to get and set the attribute, all other code can only get the attribute.