Skip to main content

PrivateCode is a Python library that provides a decorator to make a function, method, or class private.

Project description

PrivateCode

Downloads Version Python Version

PrivateCode is a Python library that provides a decorator to make a function, method, or class private. This allows the function, method, or class to be accessed only from its own module and raises an exception if called from another module. WARNING : Functions are not private at the memory level, but only at the call level.

Set up


Install

pip install PrivateCode

Upgrade

pip install --upgrade PrivateCode

Support

If you want to contact me for questions, bugs, or problems or other: lixnew2@gmail.com

Python version

PrivateCode was written for Python 3.

Decorator

Make a function, method, or class private

@private

Decorator Documentation

private

A decorator that makes a function, method, or class private, allowing it to be called only from its own module.

Arguments:

  • target: The function, method, or class to be decorated.

Returns:

  • The decorated function, method, or class.

Raises:

  • ValueError: If the decorated function, method, or class is called from a different module.

Example:

@private
def my_private_function():
    # This function can only be called from its own module.
    pass

class MyClass:
    @private
    def my_private_method(self):
        # This method can only be called from its own module.
        pass

@private
class MyPrivateClass:
    # This class can only be instantiated from its own module.
    pass

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

privatecode-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

PrivateCode-1.0.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: privatecode-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.2

File hashes

Hashes for privatecode-1.0.0.tar.gz
Algorithm Hash digest
SHA256 db9149114931cd8df06ad9779f6955a1228d10700edf8531ef2e13b53d3192b5
MD5 c7281bcd5415525bd4d629b700ab7814
BLAKE2b-256 c06d437f47dc8429f15914ea948ea671fd3322cbc6190243ba06bd1d326cae67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PrivateCode-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.2

File hashes

Hashes for PrivateCode-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 085cd52fa93a6d190a5406c9905e4adb8ac278aa5a957c0dc52ddba1f7dff185
MD5 2ec4d3c1abb7bece9fcf75aab1a25c17
BLAKE2b-256 c84a8dfe8db0edeb8c1b42dfec412d96127e4ebef45916991a796a2edd1f4795

See more details on using hashes here.

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