"Válas Péter" <[email protected]> wrote
I can create files and write strings/unicodes.
Is it possible to write a list, a dictionary or an object or
anything into a
file? Or do I have to transform them to strings?
You can write anything to a file, but the file will need to
be opened in binary mode(see the docs). The tricky bit
is reading the data back, you will need to find a way
to convert the bytes read from the file into whatever
the original data structure was.
For that reason it is usually better to use a tool like
pickle or shelve to store Python objects in a file
(again see the docs)
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor