I have a class where I pass a list of documents, and in a method, it creates a list of those documents:
class Copy(object):
def __init__(self, files_to_copy):
self.files_to_copy = files_to_copy
Here, it creates a list of files:
def create_list_of_files(self):
mylist = []
with open(self.files_to_copy) as stream:
for line in stream:
mylist.append(line.strip())
return mylist
Now, I try to access the method in another method in the class:
def copy_files(self):
t = create_list_of_files()
for i in t:
print i
Then I run the following under if __name__ == "__main__"
:
a = Copy()
a.copy_files()
This throws:
TypeError: create_list_of_files() takes exactly 1 argument (0 given)
Am I using the method wrong?