TableAttribute#
- class astropy.table.TableAttribute(default=None)[源代码]#
-
为表子类定义自定义属性的描述符。
的值
TableAttribute
将存储在一个名为__attributes__
存储在表中meta
. 属性可以按照通常的方式访问和设置,并且可以在创建对象时提供。通过这种机制定义属性可以确保在对表进行切片或序列化(例如,作为pickle或ECSV文件)时它将保持不变。
见
MetaAttribute
其他详细信息。- 参数:
- default :
object
对象 属性的默认值
- default :
实例
>>> from astropy.table import Table, TableAttribute >>> class MyTable(Table): ... identifier = TableAttribute(default=1) >>> t = MyTable(identifier=10) >>> t.identifier 10 >>> t.meta OrderedDict([('__attributes__', {'identifier': 10})])