def read_configfile(filename, separator = ':'):
    """read_configfile(filename, separator = ':')
This function reads a configuration file, extracting <keyword>, <value> pairs
to a dictionary.

Parameters:
- filename: name of the file to be read
- separator: character used to separate the <keyword> from the <value>

Return value:
- a dictionary containing the <keyword>, <value> pairs.

Notes about the configuration file format:
- A <keyword>, <value> pair must fit on one line.
- A line, a keyword, or a value may start with as many blank characters as fit,
    those will be ignored and won't appear in the result.
- Comments start with a "#".
- One can not mix values and comment on a line."""
    # This will store values read in the file as strings.
    result = {}

    # Opening the file for reading    
    file = open(filename, 'r')

    # try/finally block to ensure the file is ALWAYS correctly closed.    
    try:

        # Reading the file line by line.
        while 1:
            # Reading a line. A line may start/end with blanks that we wish
            # to ignore.
            line_with_blanks = file.readline()

            # If nothing is read, the end of line has been reached, we get out
            # of the loop.
            if not line_with_blanks: break
            
            # Stripping the leading/trailing blanks.
            line = line_with_blanks.strip()

            # if the line was only made of blanks, or starts with a "#", it is
            # of no interest.
            if not line or (line[0] == '#'): continue

            # Seperating the <keyword> from the <value>.
            split_line = line.split(separator, 1)

            # Stripping leading/trailing blanks from the keyword and the
            # value. Storing the value as a string in "values".
            keyword = split_line[0].strip()
            result[keyword] = split_line[1].strip()

    # The file is now useless. We close it.
    finally:
        file.close()

    return result