def _setattrs(self, name=None, verbose=True): """ Setting attributes of itself by calling function's named arguments. """ args = getargvalues(stack()[1][0])[-1] args = dz.keyfilter(lambda k: k not in ["self", "__class__"], args) if name is None: name = self.__class__.__name__ self.logging.debug(f"Creating {name}") for k, v in args.items(): self.logging.debug(f" Setting key-value pair {k}: {v}") setattr(self, k, v)
def test_keyfilter(self): D, kw = self.D, self.kw assert keyfilter(iseven, D({1: 2, 2: 3}), **kw) == D({2: 3})
def test_keyfilter(): assert keyfilter(iseven, {1: 2, 2: 3}) == {2: 3}