PrivateConstructorMeta¶
- 
class lsst.daf.butler.core.utils.PrivateConstructorMeta¶
- Bases: - type- A metaclass that disables regular construction syntax. - A class that uses PrivateConstructorMeta may have an - __init__and/or- __new__method, but these can’t be invoked by “calling” the class (that will always raise- TypeError). Instead, such classes can be called by calling the metaclass-provided- _constructclass method with the same arguments.- As is usual in Python, there are no actual prohibitions on what code can call - _construct; the purpose of this metaclass is just to prevent instances from being created normally when that can’t do what users would expect.- ..note: - Classes that inherit from PrivateConstructorMeta also inherit the hidden-constructor behavior. If you just want to disable construction of the base class, `abc.ABCMeta` may be a better option. - Examples - Given this class definition::
- class Hidden(metaclass=PrivateConstructorMeta): - def __init__(self, a, b):
- self.a = a self.b = b
 
 - This doesn’t work: - >>> instance = Hidden(a=1, b="two") TypeError: Hidden objects cannot be constructed directly. - But this does: - >>> instance = Hidden._construct(a=1, b="two") - Methods Summary - __call__(*args, **kwds)- Disabled class construction interface; always raises - TypeError.- mro($self, /)- Return a type’s method resolution order. - Methods Documentation - 
__call__(*args, **kwds)¶
- Disabled class construction interface; always raises - TypeError.
 - 
mro($self, /)¶
- Return a type’s method resolution order.