From 7c3d2cd5dc8401e645e4b0e06620d684171f7ccd Mon Sep 17 00:00:00 2001 From: lukew3 Date: Thu, 17 Dec 2020 14:53:12 -0500 Subject: [PATCH] Fix genById missing args/kwargs --- mathgenerator/funcs/basic_math/addition.py | 3 +++ mathgenerator/mathgen.py | 4 ++-- test.py | 10 ++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mathgenerator/funcs/basic_math/addition.py b/mathgenerator/funcs/basic_math/addition.py index cab6dac..561c9ce 100644 --- a/mathgenerator/funcs/basic_math/addition.py +++ b/mathgenerator/funcs/basic_math/addition.py @@ -2,6 +2,9 @@ from .__init__ import * def additionFunc(maxSum=99, maxAddend=50): + print(maxSum) + if maxAddend > maxSum: + maxAddend = maxSum a = random.randint(0, maxAddend) # The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well b = random.randint(0, min((maxSum - a), maxAddend)) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index af26ac4..55c1839 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -6,9 +6,9 @@ genList = getGenList() # || Non-generator Functions -def genById(id): +def genById(id, *args, **kwargs): generator = genList[id][2] - return (generator()) + return (generator(*args, **kwargs)) def make_worksheet(title): diff --git a/test.py b/test.py index 2c51d56..a29b04c 100644 --- a/test.py +++ b/test.py @@ -5,12 +5,14 @@ from mathgenerator import mathgen # print(mathgen.addition()) # prints each generator in genList -list = mathgen.getGenList() -for item in list: - print(item[2]) +# list = mathgen.getGenList() +#for item in list: +# print(item[2]) # print(mathgen.getGenList()) -print(mathgen.genById(10)) +#print(mathgen.genById(10)) #Make a pdf with 10 problems of generator id 1 # mathgen.makePdf(0, 10) + +print(mathgen.genById(0, maxSum=20))