lifehacks.metaclasses 
Structure
📦 lifehacks.metaclasses
├── meta
├── enum
└── EnumException
Installation
pip install lifehacks.metaclasses
Usage
meta metaclass
There are a few ways to make an meta class.
from lifehacks.metaclasses import meta
class myenum0(metaclass=meta): ...
@meta # preferred method
class myenum1: ...
@meta() # do not use this method
class myenum2: ...
enum metaclass
Same with meta metaclass from above,
there are a few ways to make an enum class.
from lifehacks.metaclasses import enum
# with typing
class MyPalette0(metaclass=enum[Colour]): ...
@enum # preferred method
class MyPalette1: ...
@enum[Colour] # syntax only allowed python>=3.9
class MyPalette2: ...
@enum() # do not use this method
class MyPalette3: ...
usage example:
from lifehacks.metaclasses import enum
@enum
class BasePalette:
BLACK = ...
WHITE = ...
# extending base palette enum
class SubPalette(BasePalette):
RED = ...
GREEN = ...
# can be used in type hinting
def print_colours(palette:enum) -> None:
for name, value in palette:
print(name, value)
print_colours(BasePalette) # BLACK, WHITE
print_colours(SubPalette) # BLACK, WHITE, RED, GREEN
print(BasePalette.BLACK in SubPalette) # True
enum classes are not instantiable, more on that below.
EnumException
enum classes are not instantiable.
If you try to, you get an EnumException
@enum
class Palette: ...
p = Palette() # illegal, raises EnumException
Contributors
- Simon - mightbesimon
- you?
Metadata
Release files for lifehacks.metaclasses 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lifehacks.metaclasses-1.2.4.tar.gz | 4.1 kB | Without provenance | Details for lifehacks.metaclasses-1.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lifehacks.metaclasses-1.2.4-py3-none-any.whl | Python 3 | none | any | Details for lifehacks.metaclasses-1.2.4-py3-none-any.whl |
Total release size: 12.2 kB
Release files / lifehacks.metaclasses-1.2.4.tar.gz
| Download URL | lifehacks.metaclasses-1.2.4.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
701041d18a3f4b2b28249e8ead70f7d61c6e8f66eb2049ef6afa4c876b0be87d
|
|
BLAKE2b-256 checksum How to use checksums |
0afcbf48674af8a5ad44d617f4da54269b210cfcfc20a6e1d703cf0287a372bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / lifehacks.metaclasses-1.2.4-py3-none-any.whl
| Download URL | lifehacks.metaclasses-1.2.4-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db058ab78fe419cdeff0554050e9be6e5e10ec9760d2aefd04fcdaf5510c9189
|
|
BLAKE2b-256 checksum How to use checksums |
0517335515c8502aa815ed0b96df9d8e54edfe8bc1874fdadbf56368960a0884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Security for lifehacks.metaclasses 1.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.