A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-January/060033.html below:

[Python-Dev] The path module PEP

[Python-Dev] The path module PEP [Python-Dev] The path module PEPIan Bicking ianb at colorstudy.com
Tue Jan 24 22:58:36 CET 2006
BJörn Lindqvist wrote:
>     * Functions for reading and writing a whole file - better handled
>       by file objects read() and write() methods.

I would be disappointed to see this left out, because I get really tired 
of this little dance:

   f = open(filename)
   c = f.read()
   f.close()
   return c

Then you can put a try:finally: in there too for extra correctness. 
Anyway, I write this code all the time, and it's really tiresome. 
open(filename).read() also works, but relies on Python's reference 
counting to be really reliable; maybe I shouldn't worry about that and 
use just that form.  But that bothers me too.  The same occurs during 
writing.

The original Path object has a bytes and text method (I think), which 
nicely distinguishes between the two cases.  This helps suggest better 
and more explicit handling of unicode, something that Python should work 
harder at making clear.


-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4