Getting happier ;-), but wondering if I'm thinking pythonically
Brian Quinlan
brian at sweetapp.com
Tue May 20 20:20:05 EDT 2003
Timothy Delaney wrote:
> In CPython. Except that if you don't explicitly close files that you
are
> *writing* then you may find that data isn't flushed.
How so? Unless the file object is participating in a cyclic data
structure, when will it not be collected?
> Get used to explicitly closing files - and do it in a finally: block!
No.
> But there's no harm, and can be useful as documentation - especially
if
> you have multiple exit points in a function - it can be very useful to
> have the consistency of *every* exit point being a 'return'.
I disagree. The more code that I can see on a screen, the better I can
perceive its logic. Redundant statements just reduce the amount of code
that I can see at once.
> > the decision to exit an application should be made close to the
> > top level (this is true of other languages with exception handling)
> > (e.g. line 52)
> Not necessarily. If there is a fatal condition, choosing to exit at
that
> point is fine.
How does library code know what constitutes a "fatal condition"?
> > 5. you should generate more descriptive error messages (e.g. line
30)
>
> This is related to my comments for point 4. A stack trace is much more
> descriptive ;)
But probably scary and useless to the user.
Cheers,
Brian
More information about the Python-list
mailing list