treevalue.utils.final

FinalMeta

class treevalue.utils.final.FinalMeta(name, bases, attrs)[source]
Overview:

A meta class for making one class be final (unable to be extended by other classes)

static __new__(mcs, name, bases, attrs)[source]
Overview:

Creation process of new finalized class.

Arguments:
  • name (str): Name of the new created class

  • bases (Tuple[type]): Base classes of the new created class

  • attrs (: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
>>>