Vector to string, save in file and again to vector? Python
Question: this is my first question, sorry for my english.

I have already search, but hmm, i didn't know how to search and i try
different ways and keywords, but nothing.

The problem is this:

I'm doing some scripts in blender with python and i want to use config parser
to save and load items, etc. But for example if i want to save a color, that
in blender is a Vector of 4 float places, putting the vector in a file with
config parser, it obviusly save a string in the file, Example (variable config
is all the config parser stuff):

    
    
    vector_color = [ 0.1, 0.8, 0.2, 1.0 ]
    config.set("section", "item", vector_color)
    

it's gonna save this:

> [section]  
>  item = <Vector (0.1, 0.8, 0.2, 1.0)>

such is a good thing because it stores the vector, but now.. the problem, i
want to load the vector, and how i can do that? thats my question, because if
i load it like a vector, it is a string, so.. how i can convert it again to
vector? i prove with eval(), literal_eval(), config.read_string(), i don't
know i prove with many probably functions.

so, with less words:

how i can convert this string:

    
    
    "<Vector (0.1, 0.8, 0.2, 1.0)>"
    

to this vector

    
    
    [0.1, 0.8, 0.2, 1.0]
    


Answer: If you need to save the actual object - save a _list_ instead of a file with
the characters "[1, 2, 3]" in it - I would highly recommend looking at
`pickle`.

    
    
    import pickle
    
    my_list = [1, 1, 2, 3, 5]
    pickled_list = pickle.dumps(my_list)
    f = open('my_file.py', 'w')
    f.write(pickled_list)
    f.close()
    
    #a wild coding appears...
    #you used python... it's super effective
    
    f = open('my_file.py', 'r')
    read_file = f.read()
    my_loaded_list = pickle.loads(read_file)
    f.close()
    
    my_loaded_list ##should be the list you just saved
    

'pickle' is great. Check the official Python docs.

