Предположим, у меня есть следующий дескриптор столбца PyTable:
import numpy as np
import tables as pt
class Date_t(pt.IsDescription):
year = pt.Int32Col(shape=(), dflt=2013, pos=0)
month = pt.Int32Col(shape=(), dflt=1, pos=1)
day = pt.Int32Col(shape=(), dflt=1, pos=2)
class Info(pt.IsDescription):
col1 = pt.Int32Col(shape=(), dflt=0, pos=0)
startdate = Date_t()
birthdate = Date_t()
col2 = pt.Int32Col(shape=(), dflt=0, pos=3)
enddate = Date_t()
col3 = pt.Int32Col(shape=(), dflt=0, pos=5)
col4 = pt.Int32Col(shape=(), dflt=0, pos=6)
Как указать положение «даты начала», «даты рождения» и «даты окончания»?
Я подумал, что могу сделать что-то вроде:
startdate = Date_t(pos=1)
birthdate = Date_t(pos=2)
и переопределить класс Date_t как:
class Date_t(pt.IsDescription):
def __init__(self, pos):
self._v_pos = pos
year = pt.Int32Col(shape=(), dflt=2013, pos=0)
month = pt.Int32Col(shape=(), dflt=1, pos=1)
day = pt.Int32Col(shape=(), dflt=1, pos=2)
но это дает мне ошибку:
TypeError: object.new() не принимает параметров
Любые идеи?