Python's "only one way to do it" philosophy isn't good?

Douglas Alan doug at alum.mit.edu
Sat Jun 30 14:06:09 EDT 2007


Michele Simionato <michele.simionato at gmail.com> writes:

>> Right.  So?  I understand this issue completely and I code
>> accordingly.

> What does it mean you 'code accordingly'? IMO the only clean way out
> of this issue is to NOT rely on the garbage collector and to manage
> resource deallocation explicitely, not implicitely.

(1) I don't rely on the refcounter for resources that ABSOLUTELY,
POSITIVELY must be freed before the scope is left.  In the code that
I've worked on, only a small fraction of resources would fall into
this category.  Open files, for instance, rarely do.  For open files,
in fact, I actually want access to them in the traceback for debugging
purposes, so closing them using "with" would be the opposite of what I
want.

(2) I don't squirrel away references to tracebacks.

(3) If a procedure catches an exception but isn't going to return
quickly, I clear the exception.

|>oug



More information about the Python-list mailing list