python 导入包就会初始化属性,而且直接调用方法的话,居然是共用同一个实例,惊了,惊了

import dispart_to_three_1 as disp1
import dispart_to_three_3 as disp3
import dispart_to_three_2 as disp2

list_be_cut_well = disp1.postman_class().cut_stock_list() # stock列表切块,默认500个切一片,[[n],[n],[n]]
dispart_to_three_3


class
sql_handler_class: frequency="tick" # stock_list_without_pre = ds1.postman_class().prepare_stock_list() #这个属性居然在导入包的时候就会被自动执行,我也是一脸懵啊,而且居然还和别的方法共用一个实例,我百脸懵啊 stock_list_without_pre = [] sql_util = None def __init__(self): self.stock_list_without_pre = ds1.postman_class().prepare_stock_list() self.sql_util = unr.sql_util()

猜你喜欢

转载自www.cnblogs.com/DDBD/p/12318218.html