MetaAttribute¶
- class astropy.utils.metadata.MetaAttribute(default=None)[source]¶
Bases:
objectDescriptor to define custom attribute which gets stored in the object
metadict 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
TableorNDData.This requires that the object has an attribute
metawhich 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
MetaAttributecannot 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