What is the most Pythonic way to modify the function of a function?
<p>I have a function I am using to read in files of a particular format. My function looks likes this:</p>

<pre><code>import csv
from collections import namedtuple

def read_file(f, name, header=True):
    with open(f, mode="r") as infile:
        reader = csv.reader(infile, delimiter="\t")
        if header is True:
            next(reader)
        gene_data = namedtuple("Data", 'id, name, q, start, end, sym')
        for row in reader:
            row = data(*row)
            yield row
</code></pre>

<p>I also have another type of file that I would like to read in with this function. However, the other file type needs a few slight parsing steps before I can use the <code>read_file</code> function. For example, trailing periods need to be striped from column <code>q</code> and the characters <code>atr</code> need to be appended to the <code>id</code> column. Obviously, I could create a new function, or add some optional arguments to the existing function, but is there a simple way to modify this function so that it can be used to read in an additional file type(s)? I was thinking of something along the lines of a decorator?</p>
