New submission from Adrián Deccico <decc...@gmail.com>:

Hi, in "Exceptions" section. 

Instead of using:

def get_status(file):
    fp = open(file)
    try:
        return fp.readline()
    finally:
        fp.close()

Why no suggest this method:

def get_status(file):
    with open(file) as fp:
        return fp.readline()


which will properly close the file.

----------
assignee: d...@python
components: Documentation
messages: 104111
nosy: Adrián.Deccico, d...@python
severity: normal
status: open
title: enhacement proposal in http://docs.python.org/howto/doanddont.html
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to