def to_unicode(obj, encoding='utf-8', force_string=False):

    if force_string and not isinstance(obj, basestring):
        # some sort of other object. Try to
        # convert it to a string representation.
        if hasattr(obj, '__str__'):
            obj = obj.__str__()
        elif hasattr(obj, '__unicode__'):
            obj = obj.__unicode__()
        else:
            # last resort
            obj = str(obj)

    if isinstance(obj, basestring) and not isinstance(obj, unicode):
        try:
            obj = unicode(obj, encoding)
            return obj
        except UnicodeDecodeError:
            for alt_encoding in ENCODINGS:
                try:
                    obj = unicode(obj, alt_encoding)
                    return obj
                except UnicodeDecodeError:
                    pass
        raise Exception("Error: '%s' contains invalid character(s) not in %s." % (obj, encoding))
    return obj
Gets the attribute value.
dataset/ETHPy150Open evennia/evennia/evennia/utils/utils.py/to_unicode--crossover with--dataset/ETHPy150Open apiad/sublime-browser-integration/selenium/webdriver/remote/webelement.py/WebElement.get_attribute