How can I refactor these two functions to be more DRY?
<p>I have the following two Python functions:</p>

<pre><code>@classmethod
def serialize_dict(cls, d):
    values = []
    for column_name in cls().distinguishing_column_names():
        value = str(d[column_name])
        if value == 'None':
            value = ''
        values.append(value)
    return ' '.join(values)

@classmethod
def serialize_row(cls, row):
    values = []
    for column_name in cls().distinguishing_column_names():
        value = str(row.value(cls()._meta.db_table, column_name))
        if value == 'None':
            value = ''
        values.append(value)
    return ' '.join(values)
</code></pre>

<p>As you can see, the two functions are identical except for the first line of the <code>for</code> loop. Not very DRY. How could I refactor this code to take out all the repetitions, given that <code>row</code> and <code>d</code> are of different types (<code>dict</code> and a custom type of mine, respectively)?</p>
