Skip to main content

Python decorators to specify the accessibility or scope of functions

Project description

PyPiVersion SupportedVersions License

Installation

Built and tested on Python 3.12.
No requirements other than the module itself.

pip install python-access-modifiers

Example Usage

Creating a private method inside of a class

from python_access_modifiers import private

class Example():
    @private
    def private_method(self) -> None:
        print("Private method called")

    def public_method(self) -> None:
        print("Public method called")
        self.private_method()

example_class = Example()
example_class.public_method()

Output

Public method called
Private method called

A PermissionError would be raised if the private_method method was called directly from outside the class scope.

example_class.private_method()

Output

PermissionError: Cannot invoke private method "private_method" from scope <module>

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

python_access_modifiers-1.0.0.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_access_modifiers-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file python_access_modifiers-1.0.0.tar.gz.

File metadata

  • Download URL: python_access_modifiers-1.0.0.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for python_access_modifiers-1.0.0.tar.gz
Algorithm Hash digest
SHA256 45460f0a14a6b7992584bd78105f48012a2a18a84b9923f239d428119fd0e2ea
MD5 18403e49e98acafa15021b62b16b8afd
BLAKE2b-256 af66fd6cd31d1800ed82b1e4e3c49a69e5bdd18189145a7e4ad95bf99d5387ea

See more details on using hashes here.

File details

Details for the file python_access_modifiers-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_access_modifiers-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c90d6ef1b53381873b0ce72ca735e8e1f5fa8caf4777207400d2e78829b9ebc2
MD5 73dc10b998c57697c288ffabdb98a950
BLAKE2b-256 aafb288c1cd5995217e027192e1e4714ad1ffd4123fc7f7d3ecaea838fcde78d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page