embolalia/willie — pull request #588 by xZise (2014-08-08 14:03:09+00:00)
Title: Encode the log with UTF-8 (and also use "with-as");

As the title says: When I used it in Python 2.7 and executed ".xkcd äöüß" it failed in write with:

```
Signature: UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-9: ordinal not in range(128) (file "/home/xzise/Programms/willie/willie/tools.py", line 443, in write)
from xZise at 2014-08-08 15:14:10.827730:
Message was: .xkcd äöüß
Traceback (most recent call last):
File "/home/xzise/Programms/willie/willie/bot.py", line 741, in call
exit_code = func(willie, trigger)
File "/home/xzise/Programms/willie/willie/modules/xkcd.py", line 68, in xkcd
print trigger
File "/home/xzise/Programms/willie/willie/tools.py", line 443, in write
logfile.write(string)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-9: ordinal not in range(128)
```

But to be honest, I'm never sure if that is the best fix for that in python. As far as I know in Python 3 open itself also supports `encoding`.