Code downloads a text file from a website, saves it to local disk, and then loads it into a list for further processing My program opens a website and downloads a text file.  The text file is a simple file with one word per line. I save the file to local disk and then create a list to hold each line of the text file for later processing.  I would like to know if I am doing these first steps in a way that would be considered idiomatic Python and have I made any big mistakes that will hamper my efforts to expand on it later.

This is similar to an exercise in Think Python by Allen Downey.  He suggests using a browser to download the text file but I wanted to do it with Python.  

import requests

def get_webpage(uri):
    return requests.get(uri)


def save_webpagecontent(r, filename):
    """ This function saves the page retrieved by get_webpage. r is the 
    response from the call to requests.get and
    filename is where we want to save the file to in the filesystem."""

    chunk_size = 8388608                # number of bytes to write to disk in each chunk
    with open(filename, 'wb') as fd:
        for chunk in r.iter_content(chunk_size):
            fd.write(chunk)


def make_wordlist(filename):
    wordlist = []
    with open(filename) as fd:
        wordlist = fd.readlines()
    return wordlist


def get_mylist(wordlist, num_lines=10):
    if len(wordlist) &lt;= num_lines:
        return wordlist
    return wordlist[:num_lines]


def print_mylist(mylist):
    for word in mylist:
        print(word.strip())
    return None

"""List of words collected and contributed to the public domain by
Grady Ward as part of the Moby lexicon project. See https://en.wikipedia.org/wiki/Moby_Project
"""
uri = 'https://ia802308.us.archive.org/7/items/mobywordlists03201gut/CROSSWD.TXT'
filename = 'wordlist.txt'

r = get_webpage(uri)
save_webpagecontent(r, filename)
wordlist = make_wordlist(filename)
mylist = get_mylist(wordlist)
print_mylist(mylist)


My program works as I expect it to.  I have basically found how to do each individual piece by reading this forum and but I would like to know if I'm putting all the pieces together correctly.  By correctly I mean something that not only functions as expected but also will be easy to build larger programs and modules from.

I hope it isn't wrong of me to post this much code.  I wasn't sure how I could trim it down and still show what I am doing.  Please let me know if I need to change the format of my question.
Your code is nice and concise however there are some changes you can make:


You can just return f.readlines() in make_wordlist.
If you've done this to show that the result is a list then it'd be better to use the typing module.

from typing import List


def make_wordlist(filename: str) -&gt; List[str]:
    ...

get_mylist can be replaced with wordlist[:numlines]. This is because if len(wordlist) is smaller or equal to numlines, then it will return the entire thing anyway.
Performance wise it's best to use print('\n'.join(list)) rather than for item in list: print(item).
I would prefer to be able to change chunk_size in save_webpagecontent and so you can make it a default argument.
IIRC multi-line docstrings shouldn't start on the same line as the """, nor should they end on the same line either.


import requests
from typing import List

Response = requests.Response


def get_webpage(uri) -&gt; Response:
    return requests.get(uri)


def save_webpagecontent(r: Response, filename: str,
                        chunk_size: int=8388608) -&gt; None:
    """
    This function saves the page retrieved by get_webpage. r is the 
    response from the call to requests.get and
    filename is where we want to save the file to in the filesystem.
    """
    with open(filename, 'wb') as fd:
        for chunk in r.iter_content(chunk_size):
            fd.write(chunk)


def read_wordlist(filename: str) -&gt; List[str]:
    with open(filename) as fd:
        return fd.readlines()


def print_mylist(word_list: List[str]) -&gt; None:
    print('\n'.join(word.strip() for word in word_list))


"""
List of words collected and contributed to the public domain by
Grady Ward as part of the Moby lexicon project. See https://en.wikipedia.org/wiki/Moby_Project
"""
uri = 'https://ia802308.us.archive.org/7/items/mobywordlists03201gut/CROSSWD.TXT'
filename = 'wordlist.txt'

r = get_webpage(uri)
save_webpagecontent(r, filename)
print_mylist(read_wordlist(filename)[:10])