Reputation: 29
I am trying to read through lines of a text file to split and pull strings that are between # signs. When I run my code I am getting the error
RuntimeError: maximum recursion depth exceeded
Here is my code below, any help would be greatly 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 to a file
parameterFile.write('\n'+temp2+'\n')
#check for multiple instance on the same line
if temp3.count('#') > 0:
parameterPull(temp3)
#make replacements
for eachLine in resultFile:
parameterPull(eachLine)
parameterFile.close()
Upvotes: 0
Views: 644
Reputation: 78780
You need line
instead of eachLine
in the function body. I made a quick test with a sample resultFile
(several lines of # x # y # z #
) and no error occurred after making the change.
Upvotes: 1