import sys, re def remove_comments(source): """ Returns 'source' minus docstrings. """ comments = re.findall(r"'''[s\S]*?'''", source) print(comments) #return out filename = '%s' %(sys.argv[1]) output = '%s' %(sys.argv[2]) with open(filename, newline='') as f: content = f.read() content = remove_comments(content) with open(output, 'w') as file_object: file_object.write(content)