confusion about opening files

Mark McEahern marklists at
Tue Sep 24 04:44:13 CEST 2002

> I am trying to open a file,
> >>> import os
> >>> file ="e:\\d12", "r")
> Traceback (most recent call last):
>   File "<pyshell#4>", line 1, in ?
>     file ="e:\\d12", "r")
> TypeError: an integer is required
> I get this error if the mode is r, r+, a+ or whatever.  I also get it
> whether the file exists or not. Can someone explain what I am doing wrong?

This is a FAQ.  You should probably find the Python FAQ and read it.  Short
story:  Don't use 'from x import *' unless you know what you're doing.


// m


More information about the Python-list mailing list