473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

file -> open in stdlib patch

Hi list,

AFAIK using file( ) to open a file is deprecated in favor of open( )
and while grepping through the stdlib I noticed a couple of occurences
of file( ) in the latest revision. I made a patch for getting rid of
them; it passes all the tests. Although the change is almost trivial,
since this is my first patch maybe it's better if someone
knowledgeable takes a look at it before submitting it to SF.

Daniel

Index: Lib/site.py
================================================== =================
--- Lib/site.py (revision 53548)
+++ Lib/site.py (working copy)
@@ -274,7 +274,7 @@
for filename in self.__files:
filename = os.path.join(dir, filename)
try:
- fp = file(filename, "rU")
+ fp = open(filename, "rU")
data = fp.read()
fp.close()
break
Index: Lib/webbrowser.py
================================================== =================
--- Lib/webbrowser.py (revision 53548)
+++ Lib/webbrowser.py (working copy)
@@ -216,7 +216,7 @@
cmdline = [self.name] + raise_opt + args

if remote or self.background:
- inout = file(os.devnull, "r+")
+ inout = open(os.devnull, "r+")
else:
# for TTY browsers, we need stdin/out
inout = None
@@ -340,7 +340,7 @@
else:
action = "openURL"

- devnull = file(os.devnull, "r+")
+ devnull = open(os.devnull, "r+")
# if possible, put browser in separate process group, so
# keyboard interrupts don't affect browser as well as Python
setsid = getattr(os, 'setsid', None)
Index: Lib/pstats.py
================================================== =================
--- Lib/pstats.py (revision 53548)
+++ Lib/pstats.py (working copy)
@@ -173,7 +173,7 @@

def dump_stats(self, filename):
"""Write the profile data to a file we know how to load back."""
- f = file(filename, 'wb')
+ f = open(filename, 'wb')
try:
marshal.dump(self.stats, f)
finally:
Jan 24 '07 #1
0 1174

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
0
by: chris | last post by:
I'm writing a small app to help me learn more about cryptography. All it does is encrypt all of the files in directory A, and put the encrypted versions of the files in directory B. It then...
2
by: Pierre Rouleau | last post by:
Greetings, I'm wondering why the >> operator does not use the write() method of a class derived from the built-in file class as in DerivedFile below. In the following example: - StringFile...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
1
by: Mika M | last post by:
I have made Setup and Deployment Project for my application. This application uses couble of Crysral Report .rpt -files, so I included following into Setup and Deployment Project ... -...
0
by: thjwong | last post by:
I'm using WinXP with Microsoft Visual C++ .NET 69462-006-3405781-18776, Microsoft Development Environment 2003 Version 7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1 Most developers...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.