Re: What is the correct way to port codecs.open to python 3.1?
by Baptiste Lepilleur other posts by this author
Nov 7 2009 6:45AM messages near this date
Re: What is the correct way to port codecs.open to python 3.1?
|
extracting info from media files
2009/11/7 MRAB <python@[...].com>
> Baptiste Lepilleur wrote:
>
[..]
> > Do I need to replace all codecs.open with the built-in open function? If
> > so, why does codecs.open still exist?
> >
> > The documentation says of codecs.open() that "Files are always opened in
> binary mode, even if no binary mode was specified", but you've given the
> mode as 'rt', so you're asking it to open the file both in text mode
> _and_ binary mode. This is the same as in Python 2.6.
>
> If it works in 2.6 but not in 3.1, perhaps it's just that in 2.6 it
> ignores the 't' whereas in 3.1 it complains.
>
So I did miss something, but it was in 2.6. Thanks for the clarification.
Though, I think the documentation is somewhat confusing in 3.x as it says
that it opens the file in binary mode, but the opened file iterator returns
str not bytes...
Thread:
Baptiste Lepilleur
Mrab
Antoine Pitrou
Baptiste Lepilleur
|