Skip to main content

Abstract class and interface definitions

Project description

Abstract class and interface definitions.

Create an abstract.Abstraction

An Abstraction is a metaclass for defining abstract classes.

Let’s define an abstract AFoo class and give it an abstract do_foo method.

Like any python class, an Abstraction can have any name, but it may be helpful to distinguish abstract classes from others by prefixing their name with A.

>>> import abc
>>> import abstracts

>>> class AFoo(metaclass=abstracts.Abstraction):
...
...     @abc.abstractmethod
...     def do_foo(self):
...         raise NotImplementedError

Abstract classes cannot be instantiated directly.

>>> AFoo()
Traceback (most recent call last):
...
TypeError: Can't instantiate abstract class AFoo with abstract method... do_foo

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

abstracts-0.0.2-py3-none-any.whl (64.9 kB view hashes)

Uploaded Python 3

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