在python中用外部类变量覆盖内部接口类变量

时间:2018-01-08 04:19:53

标签: python class abstract

我正面临以下困境......

MethodNotAllowedHttpExException

如何在抽象接口class XCEngine: def __init__(self, year, xrules=None): self.year = year if xrules is None: xrules=[] self.xrules = xrules #<------- set rules[] with this class Xchange(AbstractHolidayCalendar): # abstract interface reference rules = [] #<------- need to dynamically set the rules[] # Below is how I'm using the above snippet: def compute(self): date_index = XCEngine.Xchange().holidays(dt.datetime(self.year - 1, 12, 31), dt.datetime(self.year, 12, 31)) date_index3 = date_index.to_native_types().tolist() return date_index3 中设置rules[]列表?

我正在尝试将Xchange替换为rules[]

[增订] [向self.xrules]

添加了以下功能
XCEngine

[然后,创建对象并调用:]

def ruleswriter(self):
    XCEngine.Xchange().rules = self.xrules

[引发以下错误]:

def something():
    some = [USMartinLutherKingJr]
    XCEngine.ruleswriter(some)
    print XCEngine(2017).compute()

something()

0 个答案:

没有答案
相关问题