Python String Replace Error

I have a python script that keeps returning the following error:

TypeError: replace() takes at least 2 arguments (1 given)

I cannot for the life of me figure out what is causing this.

Here is part of my code:

inHandler = open(inFile2, 'r')
outHandler = open(outFile2, 'w')

for line in inHandler:

    str = str.replace("set([u'", "")
    str = str.replace("'", "")
    str = str.replace("u'", "")
    str = str.replace("'])", "")

outHandler.write(str)

inHandler.close()
outHandler.close()

Everything that is seen within double quotations needs to be replaced with nothing.

So set([u' should look like

Answer

This is what you want to do:

for line in inHandler:
    line = line.replace("set([u'", "")
    line = line.replace("'", "")
    line = line.replace("u'", "")
    line = line.replace("'])", "")

outHandler.write(line)

On the documentation, wherever it says something like str.replace(old,new[,count]) the str is an example variable. In fact, str is an inbuilt function, meaning you never want to change what it means by assigning it to anything.

line = line.replace("set([u'", "")
  ^This sets the string equal to the new, improved string.

line = line.replace("set([u'", "")
        ^ This is the string of what you want to change.