Skip to main content

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 methods
  • NotAnInstanceError: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

instancemethod-1.0.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

instancemethod-1.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file instancemethod-1.0.3.tar.gz.

File metadata

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

File hashes

Hashes for instancemethod-1.0.3.tar.gz
Algorithm Hash digest
SHA256 5f08f405ae57efbd4ee123475246a73d207d96adaa5ca821b9a4c933c72a820f
MD5 6765e793fdbe4e655e3ab6b4dab340cd
BLAKE2b-256 9e5a5b4f0b72809e4023038b484bbc8f5dd21f6c9fcda4a7097faf8589cd222e

See more details on using hashes here.

File details

Details for the file instancemethod-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for instancemethod-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c3471c4c0079a49e61c24d6abf3f5d81ac736fc140bc89c8c37482831aefcc06
MD5 cbe9fd178b355d46d4ad8a6c16703229
BLAKE2b-256 1e502e20f121f1fd8aa36411cb6cdc706fff4be8d254161b60079901ae2d9d35

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