def text_cleaner( source ):
    """
    >>> text = '''
    ... # options
    ... db=name # database
    ...  task=delete # task
    ... '''.splitlines()
    >>> for line in text_cleaner(text):
    ...    print(line)
    db=name
    task=delete
    """
    stripped = (line.strip() for line in source)
    partitioned = (line.partition("#") for line in stripped)
    decommented = (data.rstrip() for data, sharp, comment in partitioned)
    non_empty = (line for line in decommented if line)
    return non_empty