

def _convert_from_string(cmd, strobj):
    '\n    Converts a single object in *string form* to its equivalent python\n    type.\n\n     Python earlier than 2.6:\n    Handles floats, ints, and limited nested lists and dicts\n    (can\'t handle lists in a dict, for example, this is mainly due to\n    the complexity of parsing this rather than any technical difficulty -\n    if there is a need for @set-ing such complex structures on the\n    command line we might consider adding it).\n     Python 2.6 and later:\n    Supports all Python structures through literal_eval as long as they\n    are valid Python syntax. If they are not (such as [test, test2], ie\n    withtout the quotes around the strings), the entire structure will\n    be converted to a string and a warning will be given.\n\n    We need to convert like this since all data being sent over the\n    telnet connection by the Player is text - but we will want to\n    store it as the "real" python type so we can do convenient\n    comparisons later (e.g.  obj.db.value = 2, if value is stored as a\n    string this will always fail).\n    '

    def rec_convert(obj):
        '\n        Helper function of recursive conversion calls. This is only\n        used for Python <=2.5. After that literal_eval is available.\n        '
        try:
            return int(obj)
        except ValueError:
            pass
        try:
            return float(obj)
        except ValueError:
            pass
        if (obj.startswith('[') and obj.endswith(']')):
            'A list. Traverse recursively.'
            return [rec_convert(val) for val in obj[1:(- 1)].split(',')]
        if (obj.startswith('(') and obj.endswith(')')):
            'A tuple. Traverse recursively.'
            return tuple([rec_convert(val) for val in obj[1:(- 1)].split(',')])
        if (obj.startswith('{') and obj.endswith('}') and (':' in obj)):
            'A dict. Traverse recursively.'
            return dict([(rec_convert(pair.split(':', 1)[0]), rec_convert(pair.split(':', 1)[1])) for pair in obj[1:(- 1)].split(',') if (':' in pair)])
        return obj
    if _LITERAL_EVAL:
        try:
            return _LITERAL_EVAL(string)
        except (SyntaxError, ValueError):
            strobj = utils.to_str(strobj)
            string = ('{RNote: name "{r%s{R" was converted to a string. Make sure this is acceptable.' % strobj)
            cmd.caller.msg(string)
            return strobj
    else:
        return rec_convert(strobj.strip())

dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py _convert_from_string/VarMisuse@265/805 `strobj`->`string`