hbutils.design.final¶
- Overview:
Final class implement (not a custom design pattern, but useful for designing).
FinalMeta¶
-
class
hbutils.design.final.
FinalMeta
(name, bases, attrs)[source]¶ - Overview:
A meta class for making one class be final (unable to be extended by other classes).
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
static
__new__
(mcs, name, bases, attrs)[source]¶ - Overview:
Creation process of new finalized class.
- Arguments:
name (
str
): Name of the new created classbases (
Tuple[type]
): Base classes of the new created classattrs (:obj: Dict[str, Any]): Attached attributes (such as method and fields) of the new created class
- Example:
>>> class FinalClass(metaclass=FinalMeta): # this is a final class >>> pass >>> >>> class TryToExtendFinalClass(FinalMeta): # TypeError will be raised in compile time >>> pass >>>