def _convert_from_string(cmd, strobj):
    """
    Converts a single object in *string form* to its equivalent python
    type.

     Python earlier than 2.6:
    Handles floats, ints, and limited nested lists and dicts
    (can't handle lists in a dict, for example, this is mainly due to
    the complexity of parsing this rather than any technical difficulty -
    if there is a need for @set-ing such complex structures on the
    command line we might consider adding it).
     Python 2.6 and later:
    Supports all Python structures through literal_eval as long as they
    are valid Python syntax. If they are not (such as [test, test2], ie
    withtout the quotes around the strings), the entire structure will
    be converted to a string and a warning will be given.

    We need to convert like this since all data being sent over the
    telnet connection by the Player is text - but we will want to
    store it as the "real" python type so we can do convenient
    comparisons later (e.g.  obj.db.value = 2, if value is stored as a
    string this will always fail).
    """

    def rec_convert(obj):
        """
        Helper function of recursive conversion calls. This is only
        used for Python <=2.5. After that literal_eval is available.
        """
        # simple types
        try:
            return int(obj)
        except ValueError:
            pass
        try:
            return float(obj)
        except ValueError:
            pass
        # iterables
        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])
        # if nothing matches, return as-is
        return obj

    if _LITERAL_EVAL:
        # Use literal_eval to parse python structure exactly.
        try:
            return _LITERAL_EVAL(strobj)
        except (SyntaxError, ValueError):
            # treat as string
            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:
        # fall back to old recursive solution (does not support
        # nested lists/dicts)
        return rec_convert(strobj.strip())
dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py/_convert_from_string/original