opening a file opens it in Notepad

Simon Brunning SBrunning at
Thu Feb 6 11:22:59 CET 2003

> From:	Lance [SMTP:lbrannma at]
> 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
> 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...
You don't have:

from webbrowser import *

lying around anywhere do you, or something like it? This smells like
namespace pollution to me - i.e., you have accidentally imported another
'open' function over the top of the existing one. The 'from module import *'
form is dangerous, and should be used judiciously. I never use it at all.

Re closing your files - you don't *have* to close your files, but it's a
good idea. The current C implementation of Python will close your files for
you as soon as you drop the reference to them, but this is not guaranteed
behaviour - Jython doesn't immediately close files, and future versions of C
Python conceivably might not.

Simon Brunning
TriSystems Ltd.
sbrunning at

The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.

More information about the Python-list mailing list