readlines() question
Bjorn Pettersen
bjorn at roguewave.com
Fri Jun 9 19:05:53 EDT 2000
Aahz Maruch wrote:
>
> In article <Pine.GSO.4.10.10006092339580.29560-100000 at sundial>,
> Moshe Zadka <moshez at math.huji.ac.il> wrote:
> >
> >Ummmmm...I'm known as a professional paranoid in many places, so I usually
> >code like:
> >
> >my_file = open("blah")
> >try:
> > ...my_file.read, my_file.readlines, etc.
> >finally:
> > my_file.close()
>
> And if you're *really* paranoid ;-)
>
> try:
> my_file = open("blah")
> ...my_file.read, my_file.readlines, etc.
> finally:
> my_file.close()
> --
> --- Aahz (Copyright 2000 by aahz at netcom.com)
surely <wink>, you mean:
my_file = None
try:
my_file = open("blah")
...my_file.read, my_file.readlines, etc.
finally:
if my_file is not None:
my_file.close()
perhaps-more-useful-with-a-database-connection'ly y'rs
-b
More information about the Python-list
mailing list