opening a file opens it in Notepad
Anton Muhin
antonmuhin at sendmail.ru
Thu Feb 6 07:04:16 EST 2003
Lance wrote:
> Hi All,
>
> I'm running PythonWin build 148 on Windows XP.
>
> The following results in the file being opened in Notepad! This confuses me
> greatly. I simply want the file handle. My next line is to read the file
> into a string, using f1.read()
> Any suggestions will be appreciated.
>
> Also, I have a number of files in srcfiles. I imagine I must issue
> f1.close() each time in the loop, yes?
>
> for file in srcfiles:
> f1 = open(file,"r")
> ... do stuff...
>
> Thanks,
> Lance
>
>
Copy-paste of your code revealed no problem, pelase send the full
script. BTW, using file as a variable is really, really bad --- file is
a built-in function. Your code would be better written like this:
for fileName in srcfiles:
f = file(fileName, "r") # file is prefered to open now
HTH,
Anton
More information about the Python-list
mailing list