2013-10-11 2 views
0

테이블 메타 클래스 객체의 필드를 반복 할 수있는 방법이 있습니까? (테이블 그 자체가 아니기 때문에, 테이블이 인스턴스화되기 전에 예비 분석을해야합니다.)pytables 메타 데이터에 대한 정보 얻기

저는 파이썬에서 메타 클래스에 익숙하지 않습니다. 그래서 이것은 나에게 미스테리입니다.

class Particle(IsDescription): 
    name  = StringCol(16, pos=1) # 16-character String 
    lati  = IntCol(pos=2)  # integer 
    longi  = IntCol(pos=3)  # integer 
    pressure = Float32Col(pos=4) # float (single-precision) 
    temperature = FloatCol(pos=5)  # double (double-precision) 

답변

1

클래스의 columns 속성은 데이터 유형 값에 대한 키 이름의 컬럼 사전입니다. 그런 다음 파이썬 사전 (keys(), values ​​(), items() 등)처럼이 사전을 반복 할 수 있어야합니다.

In [7]: Particle.columns 
Out[7]: 
{'lati': Int32Col(shape=(), dflt=0, pos=2), 
'longi': Int32Col(shape=(), dflt=0, pos=3), 
'name': StringCol(itemsize=16, shape=(), dflt='', pos=1), 
'pressure': Float32Col(shape=(), dflt=0.0, pos=4), 
'temperature': Float64Col(shape=(), dflt=0.0, pos=5)} 
관련 문제