ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved