def peak_factory(peak_type, index, *args, **kw):
    """Create Peak objects
    peak_type     Type of peak object wanted
       (you could list types)
    index         index
       (you could list params for the various types)
    """
return peak_type(index, *args, **kw)

def peakfind(peak_type, xdata, ydata, **kw):
    return peak_factory(peak_type, 1, 0, 1, 0.5, 10, **kw)
How do I downcast in python