本文整理汇总了Python中Direct.ReductionHelpers.gen_setter方法的典型用法代码示例。如果您正苦于以下问题:Python ReductionHelpers.gen_setter方法的具体用法?Python ReductionHelpers.gen_setter怎么用?Python ReductionHelpers.gen_setter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Direct.ReductionHelpers
的用法示例。
在下文中一共展示了ReductionHelpers.gen_setter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setattr__
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import gen_setter [as 别名]
def __setattr__(self,name,val):
if name is 'special':
return
elif name in self.__class__.__dict__:
fp = self.__class__.__dict__[name]
fp.__set__(self,val)
else:
helpers.gen_setter(self.__dict__,name,val)
示例2: test_gen_setter
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import gen_setter [as 别名]
def test_gen_setter(self):
kkdict = {}
kkdict['A']=helpers.ComplexProperty(['B','C'])
kkdict['B']=19
kkdict['C']=1000
helpers.gen_setter(kkdict,'B',0)
self.assertEqual(kkdict['B'],0)
helpers.gen_setter(kkdict,'C',10)
self.assertEqual(kkdict['C'],10)
self.assertRaises(KeyError,helpers.gen_setter,kkdict,'A',100)
self.assertEqual(kkdict['B'],0)
helpers.gen_setter(kkdict,'A',[1,10])
self.assertEqual(kkdict['B'],1)
self.assertEqual(kkdict['C'],10)
helpers.gen_setter(kkdict,'A',(2,20))
self.assertEqual(kkdict['B'],2)
self.assertEqual(kkdict['C'],20)
示例3: test_gen_setter
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import gen_setter [as 别名]
def test_gen_setter(self):
kkdict = {};
kkdict['A']=helpers.ComplexProperty(['B','C']);
kkdict['B']=19;
kkdict['C']=1000;
helpers.gen_setter(kkdict,'B',0)
self.assertEqual(kkdict['B'],0);
helpers.gen_setter(kkdict,'C',10)
self.assertEqual(kkdict['C'],10);
self.assertRaises(KeyError,helpers.gen_setter,kkdict,'A',100)
self.assertEqual(kkdict['B'],0);
helpers.gen_setter(kkdict,'A',[1,10])
self.assertEqual(kkdict['B'],1);
self.assertEqual(kkdict['C'],10);