On Sun, 7 Mar 2010 13:23:12 +0100
Giorgio <anothernetfel...@gmail.com> wrote:

> One more question: Amazon SimpleDB only accepts UTF8.
[...]
> filestream = file.read()
> filetoput = filestream.encode('utf-8')

No! What is the content of the file? Do you think it can be a pure python 
representation of a unicode text?

uContent = inFile.read().decode(***format***)
<process, if any>
outFile.write(uContent.encode('utf-8'))

input -->decode--> process -->encode--> output

This gives me an idea: when working with unicode, it would be cool to have an 
optional format parameter for file.read() and write. So, the above would be:

uContent = inFile.read(***format***)
<process, if any>
outFile.write(uContent, 'utf-8')

Or, maybe even better, the format could be given as third parameter of file 
open(); then any read or write operation would directly convert from/to the 
said format. What do you all think?


denis
-- 
________________________________

la vita e estrany

spir.wikidot.com

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to