File Input and Output

readlines()

Example

def gen_files():
    """return a generator of dir names reading in `tempfile`

       `tempfile` has this format:

       number<int>/file_or_dir<str>,is_dir<bool>
       03/rss.xml,False
       03/tags.html,False
       ...
       03/mrogers,True
       03/alexvic,True

       -> use last column to filter out directories (= True)
    """
    with open(tempfile) as f:
        return (line.split(',')[0].lower()
                for line in f.readlines()
                if line.strip().endswith('True'))

Each line is split on the comma: line.split(','). Does not require the csv module.

When split, each line becomes a list - example:
['03/mrogers','True']

[0].lower() takes the first item in each line which is the number and user name, and lowercases it.

strip() to remove beginning and ending whitespace.

endswith('True') filters out directories.