Skip to main content

allows for @interface class partail behavoiur decorator

Project description

Interface Decorator

allows the use of the @Interface class decorator, which allows for partial interface behavior currently only preventing direct instantiation. future features hope to include method detection and force children implementations, however, this can be accomplished with the ABC package.

this package is designed to be light weight and extremely simple to use. one @ to rule them all. in this case, enforcing typical interface behaviors with good readability.

install windows

pip install InterfaceTools

Mac

pip3 install InterfaceTools

Instructions:

above any classes you wish to become an interface and restrict instantaition to only children:

from Leviathan.interface import Interface

@interface
class MyClass():

    def Method():pass

that is all there is to it. this decorator then restricts this class never to instantiate on its own; meaning the following:

foo = MyClass()

which gives the following error:

InterfaceInstancingError: The class MyClass is an interface. Interfaces cannot be instantiated.

Additionally, unlike interfaces in C# or Java, you are not required to implement their methods. however, if you desire that functionality you can use this with the ABC package to enforce children-overriding methods

example:

from abc import ABCMeta, abstractmethod

@Interface 
class myClass(metaclass=ABCMeta):
    
    @abstractmethod
    def method():pass

the example above will give you a full C# or Java-like interface.

other things you can do with this module are interface inheritance:

example:

@Interface 
class myClass():
    pass
@Interface
class class2(myClass):
    pass

which you can also inherit from regular classes as well.

class myClass():
    pass
@Interface
class class2(myClass):
    pass

the interface wrapper is fully compatible with all the default Python functions, and the ABC package for further control over your interface.

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

interfacetools-1.0.7.tar.gz (3.9 kB view details)

Uploaded Source

Built Distributions

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

InterfaceTools-1.0.7-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

InterFaceTools-1.0.7-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file interfacetools-1.0.7.tar.gz.

File metadata

  • Download URL: interfacetools-1.0.7.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for interfacetools-1.0.7.tar.gz
Algorithm Hash digest
SHA256 f7cb117c89ee0bffc428100ba8edfee8cfb4f1ad43ae184d186fa3edb9f67d53
MD5 00851a3c435708ad22aea70f8bc77cd4
BLAKE2b-256 9c111d4210e9e456e55202703b196ff7f0b3dd41d86d575f2482563b4a9803d0

See more details on using hashes here.

File details

Details for the file InterfaceTools-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: InterfaceTools-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for InterfaceTools-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e6f0fee682dc9566cde6386cd7cf6955ee06fad7ab4df0971a702648ff2988a8
MD5 370b07404950a610f1a5ec91c7567507
BLAKE2b-256 5014e33067b619ff19bf8b6d9e5886b1ab3a30814c094ea5407878436a509e5b

See more details on using hashes here.

File details

Details for the file InterFaceTools-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: InterFaceTools-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for InterFaceTools-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 554f502ae662f0a053109bf8fbe8100fc451fb2ee165ff065596db8ba2960b4c
MD5 8fe1e116be1ac631da2fadc3187a06b8
BLAKE2b-256 268697ced69fe1c182f0fa874b5aee39d2b1c2765d1503b45f720fd978ea070c

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