Opening Unicode files

Gary Herron gherron at
Wed Jul 9 17:43:58 CEST 2008

Noorhan Abbas wrote:
> Hello,
> I wonder if you don't mind helping me out in this problem. I have been 
> developing a tool in python that opens some unicode files, reading 
> them and processing the data. It is working fine. When I started to 
> write a cgi module that does the same thing for google 
> appengine(actually it is using the same files that I used befoer), I 
> get an error:
> f = (FileName , 'rU', 'utf-8')
> It says that the above functions takes 3 arguments but 4 were given.

Truly?  I ran that line and found it works perfectly.

What version of python are you using (I used 2.5.1).
What OS?  (That should not matter, however you should tell us anyway.)
Are you sure your codecs is the Python module imported normally.  (You 
may have to show us all your code.)

With no code and a careful look at your error message, here's my guess:

That error message is what you get when you call an instance's method 
with the wrong number of arguments.  (And in that case the extra 
argument it's referring to is the instance itself begin passed in as the 
first (self) parameter.)

I believe your codecs value is no longer the imported module, but rather 
some instance object you've assigned into it:
  codecs = ...something overwriting the module object ...

Gary Herron

> I wonder if I need to do something before using the codecs library 
> from within the cgi module?!
> Thank you very much for your help,
> Nora
> ------------------------------------------------------------------------
> Not happy with your email address?
> Get the one you really want <> 
> - millions of new email addresses available now at Yahoo! 
> <>
> ------------------------------------------------------------------------
> --

More information about the Python-list mailing list