MetaAttribute¶
- class astropy.utils.metadata.MetaAttribute(default=None)[source]¶
Bases:
object
Descriptor to define custom attribute which gets stored in the object
meta
dict and can have a defined default.This descriptor is intended to provide a convenient way to add attributes to a subclass of a complex class such as
Table
orNDData
.This requires that the object has an attribute
meta
which is a dict-like object. The value of the MetaAttribute will be stored in a new dict meta[‘__attributes__’] that is created when required.Classes that define MetaAttributes are encouraged to support initializing the attributes via the class
__init__
. For example:for attr in list(kwargs): descr = getattr(self.__class__, attr, None) if isinstance(descr, MetaAttribute): setattr(self, attr, kwargs.pop(attr))
The name of a
MetaAttribute
cannot be the same as any of the following:Keyword argument in the owner class
__init__
Method or attribute of the “parent class”, where the parent class is taken to be
owner.__mro__[1]
.
- Parameters:
default – default value