Fix genById missing args/kwargs

This commit is contained in:
lukew3
2020-12-17 14:53:12 -05:00
parent 18c11dff4c
commit 7c3d2cd5dc
3 changed files with 11 additions and 6 deletions

View File

@@ -2,6 +2,9 @@ from .__init__ import *
def additionFunc(maxSum=99, maxAddend=50): def additionFunc(maxSum=99, maxAddend=50):
print(maxSum)
if maxAddend > maxSum:
maxAddend = maxSum
a = random.randint(0, maxAddend) 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 # 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)) b = random.randint(0, min((maxSum - a), maxAddend))

View File

@@ -6,9 +6,9 @@ genList = getGenList()
# || Non-generator Functions # || Non-generator Functions
def genById(id): def genById(id, *args, **kwargs):
generator = genList[id][2] generator = genList[id][2]
return (generator()) return (generator(*args, **kwargs))
def make_worksheet(title): def make_worksheet(title):

10
test.py
View File

@@ -5,12 +5,14 @@ from mathgenerator import mathgen
# print(mathgen.addition()) # print(mathgen.addition())
# prints each generator in genList # prints each generator in genList
list = mathgen.getGenList() # list = mathgen.getGenList()
for item in list: #for item in list:
print(item[2]) # print(item[2])
# print(mathgen.getGenList()) # print(mathgen.getGenList())
print(mathgen.genById(10)) #print(mathgen.genById(10))
#Make a pdf with 10 problems of generator id 1 #Make a pdf with 10 problems of generator id 1
# mathgen.makePdf(0, 10) # mathgen.makePdf(0, 10)
print(mathgen.genById(0, maxSum=20))