class astropy.table.TableAttribute(default=None)[source]

Bases: astropy.utils.metadata.MetaAttribute

Descriptor to define a custom attribute for a Table subclass.

The value of the TableAttribute will be stored in a dict named __attributes__ that is stored in the table meta. The attribute can be accessed and set in the usual way, and it can be provided when creating the object.

Defining an attribute by this mechanism ensures that it will persist if the table is sliced or serialized, for example as a pickle or ECSV file.

See the MetaAttribute documentation for additional details.


Default value for attribute


>>> from astropy.table import Table, TableAttribute
>>> class MyTable(Table):
...     identifier = TableAttribute(default=1)
>>> t = MyTable(identifier=10)
>>> t.identifier
>>> t.meta
OrderedDict([('__attributes__', {'identifier': 10})])