Skip to content

Commit

Permalink
Merge pull request #22 from chillenzer/gh-pages
Browse files Browse the repository at this point in the history
Open files more idiomatically
  • Loading branch information
edbennett authored Jan 25, 2023
2 parents 28f495d + ffe70d4 commit 68c4013
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions _episodes/04-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ and pass it to `requests.post`.
First of all, let's load the GitHub access token:
~~~
ghtoken = open("github-access-token.txt",'r').read().strip()
with open("github-access-token.txt", "r") as file:
ghtoken = file.read().strip()
~~~
{: .language-python}
Expand Down Expand Up @@ -479,7 +480,8 @@ This can either be done from a file,
or by specifying the key directly in a settings file.
~~~
api_key = open("metoffice-api-key.txt",'r').read().strip()
with open("metoffice-api-key.txt", "r") as file:
api_key = file.read().strip()
~~~
{: .language-python}
Expand Down

0 comments on commit 68c4013

Please sign in to comment.