可以在“ def init”中设置未传递给函数的属性吗?像下面的这段代码一样,仅传递env。但是我希望类中的函数了解local_gdb和reference_data。
类规格:
def __init__(self, env):
self.env = env
local_gdb = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Clip.gdb")
self.local_gdb = local_gdb
self.reference_data = {
'moa_centerline': {'sde': 'MOAADM.Addressing_DBO_STREETS\MOAADM.streets',
'gdb': os.path.join(local_gdb, 'MOA_Streets')},
'moa_address': {'sde': 'MOAADM.ADDRESS_POINT',
'gdb': os.path.join(local_gdb, 'MOA_Address')},
'kpb_address': {'sde': "KPBADM.PhysicalAddress",
'gdb': os.path.join(local_gdb, "KPB_Address")},
}
答案 0 :(得分:0)
我将一流的规范重构为:
local_gdb = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Clip.gdb")
reference_data = {
'moa_centerline': {'sde': 'MOAADM.Addressing_DBO_STREETS\MOAADM.streets',
'gdb': os.path.join(local_gdb, 'MOA_Streets')},
'moa_address': {'sde': 'MOAADM.ADDRESS_POINT',
'gdb': os.path.join(local_gdb, 'MOA_Address')},
'kpb_address': {'sde': "KPBADM.PhysicalAddress",
'gdb': os.path.join(local_gdb, "KPB_Address")},
}
def __init__(self, env):
self.env = env