Skip to content

Commit

Permalink
Fixed order of operations where subsequent pages would overwrite prev…
Browse files Browse the repository at this point in the history
…ious pages, due to re-opening the file for writing
  • Loading branch information
Phrancis committed Aug 21, 2019
1 parent 590bf5d commit 8c92580
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions followers/extract_all_user_followers_ids.py
Expand Up @@ -23,9 +23,9 @@ def extract_all_user_followers_ids(screen_name: str) -> str:
_output_file_path = os.path.join(PATH_TO_APP_DATA, _output_file_name)
_followers_count: int = 0
try:
for page in tweepy.Cursor(_api.followers_ids, screen_name=screen_name).pages():
_output_file: TextIO
with open(_output_file_path, 'w') as _output_file:
_output_file: TextIO
with open(_output_file_path, 'w') as _output_file:
for page in tweepy.Cursor(_api.followers_ids, screen_name=screen_name).pages():
for item in page:
_output_file.write(f'{item}\n')
return _output_file_path
Expand Down

0 comments on commit 8c92580

Please sign in to comment.