Message104111
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. |
|
Date |
User |
Action |
Args |
2010-04-24 17:57:35 | Adrián.Deccico | set | recipients:
+ Adrián.Deccico, docs@python |
2010-04-24 17:57:35 | Adrián.Deccico | set | messageid: <1272131855.89.0.865652130353.issue8522@psf.upfronthosting.co.za> |
2010-04-24 17:57:34 | Adrián.Deccico | link | issue8522 messages |
2010-04-24 17:57:34 | Adrián.Deccico | create | |
|