diff --git a/sessions/python-02.tex b/sessions/python-02.tex index 2d82856..9d5dd8f 100644 --- a/sessions/python-02.tex +++ b/sessions/python-02.tex @@ -641,9 +641,9 @@ Mais il vaut mieux recopier le code vous-mêmes. \begin{lstlisting} def read_words(): - stream = open("pendu.txt") - contents = stream.read() - stream.close() + file = open("pendu.txt") + contents = file.read() + file.close() words = splitlines() return words \end{lstlisting} diff --git a/sources/05-airports.py b/sources/05-airports.py index d6bf844..f14b2f3 100644 --- a/sources/05-airports.py +++ b/sources/05-airports.py @@ -3,8 +3,8 @@ import sys def build_airport_dict(): result = dict() - stream = open("airports.txt", "r") - contents = stream.read() + file = open("airports.txt", "r") + contents = file.read() lines = contents.splitlines() for line in lines: words = line.split(" ", maxsplit=1) diff --git a/sources/06-top-words.py b/sources/06-top-words.py index 407fa3a..d89f4a2 100644 --- a/sources/06-top-words.py +++ b/sources/06-top-words.py @@ -17,11 +17,11 @@ def get_word(chunk): def main(): filename = sys.argv[1] - stream = open(filename, "r") + file = open(filename, "r") scores = {} - for line in stream.readlines(): + for line in file.readlines(): for chunk in line.split(): word = get_word(chunk) if word: @@ -30,7 +30,7 @@ def main(): else: scores[word] += 1 - stream.close() + file.close() main()