Raise exceptions while creating exception classes on the fly, without the need to predefine them beforehand.
Project description
gqylpy-exception
English | 中文
Raise exceptions while creating exception classes on the fly, without the need to predefine them beforehand. For instance, if you want to raise an exception named NotUnderstandError
, simply import import gqylpy_exception as ge
and execute raise ge.NotUnderstandError
directly for convenience and efficiency.
pip3 install gqylpy_exception
Using gqylpy_exception
to Create Exception Classes
import gqylpy_exception as ge
raise ge.AnError(...)
With gqylpy_exception
, you can create exception classes with arbitrary names. AnError
is not predefined in gqylpy_exception
; it is dynamically created when your code executes ge.
due to the magic method __getattr__
.
Alternatively, you can also create exceptions upon import:
from gqylpy_exception import AnError
raise AnError(...)
Lastly, gqylpy_exception
avoids duplicate creation of exception classes. Once an exception class has been created, it is stored in the ge.__history__
dictionary. When you attempt to create the same exception again, it will be retrieved from this dictionary.
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
Built Distribution
Hashes for gqylpy_exception-3.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c52cbd6b41b4e2470d3a6e97aab38e6c820bf17d9f44c83b50e3e101447c788 |
|
MD5 | e095148c5dcb801defdc4fcc95b81c3f |
|
BLAKE2b-256 | 00dd6b75e9e4b739a550c45e96e8a5db01f66e0bc5519385cefb8b801cdfaa4b |