What is file.encoding convention?

Naoki INADA songofacandy at gmail.com
Thu Jul 23 11:24:42 CEST 2009


> What is file.encoding convention?
> If I want to write a unicode string to a file(-like) that have
> encoding attribute, I should do
> (1) try: file.write(unicode_str),
> (2) except UnicodeEncodeError: file.write(unicode_str.encode
> (file.encoding))
> like logging?
> It seems agly.

s/agly/ugly/



More information about the Python-list mailing list