0

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() 
0

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.