如何在函数lambda中访问obj类?

时间:2019-05-30 09:12:34

标签: python

class obj:
    def __init(self, image_set, year):
        self._year = year
        self._image_set = image_set

__sets = {}
for year in ['2007', '2012']:
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'voc_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: obj(split, year))

我无法在每个函数lambda中访问值“ split”和“ year”

0 个答案:

没有答案