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.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: instancemethod-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e3f6b53e517c010bc96c102c70c35210ab9dd814f92a3307b4abc5f1aaa1c376
MD5 3bf9e80839a848aeb077b6d70adc3f43
BLAKE2b-256 a3255c59035e90d84e4299ec46c64b056f780d780edcffd1cdf75732fe6d5c25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for instancemethod-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a387f3852e01e8be8b57858ccf43b826edd4ee0893bc203046147d16aca026c
MD5 51e014a51a9d60c8e397f6d9eebff60f
BLAKE2b-256 1333e40ce887a1b0be95a1ee1934c5b15a9d19115c0ba7b35cd90c0f69391e3a

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