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

Lenard Lindstrom len-l at
Sun Jul 1 19:27:33 CEST 2007

Douglas Alan wrote:
> Lenard Lindstrom <len-l at> writes:
>> Explicitly clear the exception? With sys.exc_clear?
> Yes.  Is there a problem with that?

As long as nothing tries to re-raise the exception I doubt it breaks 

 >>> import sys
 >>> try:
	raise StandardError("Hello")
except StandardError:

Traceback (most recent call last):
   File "<pyshell#6>", line 5, in <module>
TypeError: exceptions must be classes, instances, or strings 
(deprecated), not NoneType

But it is like calling the garbage collector. You are tuning the program 
to ensure some resource isn't exhausted. It relies on implementation 
specific behavior to be provably reliable*. If this is indeed the most 
obvious way to do things in your particular use case then Python, and 
many other languages, is missing something. If the particular problem is 
isolated, formalized, and general solution found, then a PEP can be 
submitted. If accepted, this would ensure future and cross-platform 

* reference counting is an integral part of the CPython C api so cannot 
be changed without breaking a lot of extension modules. It will remain 
as long as CPython is implemented in C.

Lenard Lindstrom
<len-l at>

More information about the Python-list mailing list