open() error ---- what am I missing?

Eric Torstenson torstenson at no-spam.oti-hsv.com
Mon Mar 4 12:56:36 EST 2002


OK, imported __builtin__ and used __builtin__.open(blah, blah) and got the
same result, so I am guessing that is not a matter of function hiding, but
some other error that I am just being blind to.

The file name is valid and was built using the os.path.join function. The
path exists, but the file does not (it shouldn't need to exist ahead of time
since it is a write). I have tried all manner of write flags (w, wb, wb+),
all of which yield same results.

eric

"Eric Torstenson" <torstenson at no-spam.oti-hsv.com> wrote in message
news:%6Og8.10755$hK4.4027177 at e420r-atl1.usenetserver.com...
> This is really frustrating for me, and was hoping someone could point me
in
> the right direction.
>
> I have a class that I use to generate a log. It handles opens, closes and
> logging to the file.
>
> I have another class which does a lot of other stuff, and occassionally
> writes messages to the log.
>
> The program has worked fine, but when after adding a couple of details
(none
> of which affected the log), I now get:
>     Traceback (most recent call last):
>       File "pLog.py", line 10, in __init__
>         self.logInit(sFilename)
>       File "pLog.py", line 14, in logInit
>         self.fLog=open(filename, mode='w')
>     IOError: invalid argument: w
>
> I have read that you can hide built ins by doing:
>     from some_file import *
> if some_file an instance of open() exists in the *
>
> but I don't have anything like that in my code.
>
> The weirder thing, is that I can use the log in other scripts. I have even
> copied the imports to the test script, and it continues to run without
> error.
>
> Does anyone know how to determine what is hiding the builting open()
routine
> (file() does the same), or how to explicitly call the builtin.open()
> command? I had trouble with this at the very beginning (I'm still very new
> to python), but I usually was able to get it worked out.
>
> thanks,
>
> eric
>
>
>






More information about the Python-list mailing list