From: Antoine Pitrou on
On Tue, 27 Jul 2010 10:33:06 -0400
python(a) wrote:
> What is the best practice way to open files in Python 2.6+
> It looks like there are at least 3 different ways to open files:
> - built-in open()
> -
> -
> It seems like combines the best of the built-in open()
> and the codecs open(). Am I missing any obvious drawbacks to
> using except for backwards compatibility? is quite slow in 2.6, although the performance issues are
fixed in 2.7 (and in 3.1). is much stricter in what types it accepts and emits. Files
opened in text mode, for example, will return unicode strings when
reading and will only accept unicode strings for write().
(similarly, files opened in binary mode will only accept bytestrings
for write())