Restrict method calls to instances of the owner class.
Project description
instancemethod
Purpose
This package containing code and its example usage for restricting method calls to instances of the class or subclass that contains the method.
Contents
This package contains one module written in pure Python (3.5 or newer) with the following code blocks:
instancemethod
: Higher order function for wrapping methodsNotAnInstanceError
: Error raised when validation fails
Usage
Use the Python decorator (@
) symbol along with the instancemethod
function to wrap a method and designate it as an instance method.
Declaration
class Foo:
def __init__():
...
@instancemethod
def bar():
...
Valid Usage
foo = Foo()
bar = foo.bar()
Invalid Usage
bar = Foo.bar()
Returns
NotAnInstanceError:
...
Author
Braden Toone is the sole author and maintainer of this code, and can be contacted via email at braden@toonetown.com
License
This package is licensed under the OSI Approved MIT License.
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 instancemethod-1.4.0.tar.gz
.
File metadata
- Download URL: instancemethod-1.4.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2306fbf7a24722ebaf05e1e222f7367af3cc36f606a9d3486f43d96d4a3f47f |
|
MD5 | 38f4d0194814dd754c68ba4c328672ae |
|
BLAKE2b-256 | 9b10a095a792956643bdc9a1811646f55c24387f659a1c5c042dfdde1a1a83bb |
File details
Details for the file instancemethod-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: instancemethod-1.4.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a80a3abc7435f785ae09e4f36cb793c617d87ea19aae532675121a295864822 |
|
MD5 | afe3f74aeac80b14b2313c00b8129634 |
|
BLAKE2b-256 | 48317c357a7bd930aed3cb24879d3a46a0218567e4eaf3d990336cbb1e73b35b |