[Tutor] unicode files

steve king its_steevo@hotmail.com
Fri, 03 May 2002 15:30:41 +0100


Hello,

I am relatively new to Python so don't laugh if what I ask is painfully 
obvious... (or just plain wrong!!!)

I have worked out how to open a file and how to write to it, but I need the 
file to be in unicode. I know there is a unicode() function but there isn't 
a great deal of documentation on how to use it.

Is it a case of creating the file, writing to it and then saving it as 
unicode, or would I be better off writing the strings as unicode and then 
saving the file?

At the moment I have something like this:

import sys

starting_dir=raw_input("Dir and file please: ")
somename=starting_dir
file=open(somename, 'w')
file.write("The first line of a file")
file.close()


_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com