def readline_comment(file, symbol='#'):
    """Reads line from a file object, but ignores everything after the
    comment symbol (by default '#')"""
    line = file.readline()
    if not line:
        return ''
    result = line.partition(symbol)[0]
    return result if result else readline_comment(file)