> 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/