Python ABC plus abstract attributes
Project description
Better ABC
https://stackoverflow.com/questions/23831510/abstract-attribute-not-property
Usage
from better_abc import ABCMeta, abstract_attribute # see below
class AbstractFoo(metaclass=ABCMeta):
@abstract_attribute
def bar(self):
pass
class Foo(AbstractFoo):
def __init__(self):
self.bar = 3
class BadFoo(AbstractFoo):
def __init__(self):
pass
Foo() # ok
BadFoo() # will raise: NotImplementedError: Can't instantiate abstract class BadFoo
# with abstract attributes: bar
If you want other features of ABC they need to be imported from the abc module directly.
from abc import abstractmethod
from better_abc import ABCMeta, abstract_attribute
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
better-abc-0.0.3.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file better-abc-0.0.3.tar.gz
.
File metadata
- Download URL: better-abc-0.0.3.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a880fd6bc9675da2ec991e8712a555bffa0f12722efed78c739f78343cf989f6 |
|
MD5 | 7d745fa4052046f62d3f1abcc00db0f2 |
|
BLAKE2b-256 | 8b723d630f781659015357cc08cad32aa636b252e007df0bae31184a3d872427 |
File details
Details for the file better_abc-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: better_abc-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ae73b473fbeb536a548f542984976e80b821676ae6e18f14e24d8e180647187 |
|
MD5 | 6e9a0ef9b12f8717d011b37f46de7433 |
|
BLAKE2b-256 | d9e87d00a23039ab74c5741736ce05d7700eb6237e83747aac4df07a5bf2d074 |