Python's BNF
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Feb 28 11:15:14 EST 2008
En Thu, 28 Feb 2008 12:33:33 -0200, <MartinRinehart at gmail.com> escribi�:
> Implemented all your suggestions, with two exceptions.
>
> Changed file read to readlines(), but not open(...).readlines(). I
> love to say file.close(). Gives me a feeling of security. (We could
> discuss RAM waste v. I/O speed but this input file is just 10KB, so
> neither matters.)
Ok, what about this?
with open(...) as f:
for line in f:
...do something with each line...
The with statement guarantees that close (implicit) is always called.
> Removed one of the three globals, but left the other two. Couldn't see
> any real advantage to passing poor 'ofile' from hand to hand
> (writeHTML() to writeBody() to writeEntries() ...) as opposed to
> letting him rest easy in his chair, doing a little writing when
> called.
Perhaps not in this small script, but as a design principle, having a
global `ofile` object doesn't look good...
> Also changed the opening doc comment to give you appropriate credit.
No need for that.
--
Gabriel Genellina
More information about the Python-list
mailing list