From 0c08586f24f060cd1753e22030ff99cb7156a6fd Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 6 Jul 2021 11:27:13 -0500 Subject: [PATCH] Remove unnecessary use of setattr() If an attribute is referenced using a string literal, there is no reason to use setattr(). --- Bone Market Solver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bone Market Solver.py b/Bone Market Solver.py index 4264542..95b0f62 100644 --- a/Bone Market Solver.py +++ b/Bone Market Solver.py @@ -336,7 +336,7 @@ def NewIntermediateBoolVar(self, name, expression, domain): self.AddLinearExpressionInDomain(expression, domain.Complement()).OnlyEnforceIf(intermediate.Not()) return intermediate -setattr(cp_model.CpModel, 'NewIntermediateBoolVar', NewIntermediateBoolVar) +cp_model.CpModel.NewIntermediateBoolVar = NewIntermediateBoolVar del NewIntermediateBoolVar @@ -347,7 +347,7 @@ def AddApproximateExponentiationEquality(self, target, var, exp, upto): """ return self.AddAllowedAssignments([target, var], [(int(base**exp), base) for base in range(upto + 1)]) -setattr(cp_model.CpModel, 'AddApproximateExponentiationEquality', AddApproximateExponentiationEquality) +cp_model.CpModel.AddApproximateExponentiationEquality = AddApproximateExponentiationEquality del AddApproximateExponentiationEquality @@ -367,7 +367,7 @@ def AddGeneralMultiplicationEquality(self, target, *variables): product = reduce(function, variables) return self.Add(target == product) -setattr(cp_model.CpModel, 'AddGeneralMultiplicationEquality', AddGeneralMultiplicationEquality) +cp_model.CpModel.AddGeneralMultiplicationEquality = AddGeneralMultiplicationEquality del AddGeneralMultiplicationEquality