Python: RuntimeError: maximum recursion depth exceeded -
i trying read through lines of text file split , pull strings between # signs. when run code getting error
runtimeerror: maximum recursion depth exceeded
here code below, help appreciated. thanks!
#function def parameterpull(line): if line.count('#') > 0: temp = eachline.split('#',1)[1] temp2 = temp.split('#',1)[0] temp3 = temp.split('#',1)[1] #write these scripts file parameterfile.write('\n'+temp2+'\n') #check multiple instance on same line if temp3.count('#') > 0: parameterpull(temp3) #make replacements eachline in resultfile: parameterpull(eachline) parameterfile.close()
you need line
instead of eachline
in function body. made quick test sample resultfile
(several lines of # x # y # z #
) , no error occurred after making change.
python recursion runtime-error
No comments:
Post a Comment