There are two ways to call replace.
Let us start by defining a string:
In [19]: s = "set([u'"
We can call the replace method of string s:
In [20]: s.replace("u'", "")
Out[20]: 'set(['
Or, we can call the replace of the class str:
In [21]: str.replace(s, "u'", "")
Out[21]: 'set(['
The latter way requires three arguments because str. That is why you received the error about missing arguments.
What went wrong
Consider the code:
for line in inHandler:
str = str.replace("set([u'", "")
str = str.replace("'", "")
str = str.replace("u'", "")
str = str.replace("'])", "")
First, note the goal is to replace text in line but nowhere in the calls to replace is the variable line used for anything.
The first call to replace generates the error:
>>> str.replace("set([u'", "")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: replace() takes at least 2 arguments (1 given)
Used in the above form, str.replace interprets its first argument as the string to replace. It is as if you wrote:
"set([u'".replace("")
In other words, it thinks that set([u' is the string to operate on and the replace function was given just one argument: the empty string. That it why the message is replace() takes at least 2 arguments (1 given).
What you need is to operate on the variable line:
line = line.replace("set([u'", "")
And so on for the remaining lines in the loop.
stras varibale is very bad practive,stris inbuilt function