

def coerce_text(v):
    if (not isinstance(v, basestring_)):
        if (sys.version_info[0] < 3):
            attr = '__unicode__'
        else:
            attr = '__str__'
        if hasattr(v, attr):
            return unicode(v)
        else:
            return bytes(v)
    return v

dataset/ETHPy150Open mne-tools/mne-python/mne/externals/tempita/compat3.py coerce_text/original