[Python-Dev] RE: PEP-317

Steven Taschuk staschuk@telusplanet.net
2003年6月10日 17:26:10 -0600


Quoth Aahz:
 [...]
> raise Found()
> except Found:
 [...]
> I find that extra set of parentheses unnecessary and ugly. It implies a
> callable where it's not really being used that way, [...]

In
 raise Found
Found *is* being used as a callable under the hood; an instance of
Found is created implicitly. You just happen not to care about
that instance.
> [...] particularly in the
> asymmetry between the ``raise`` and the ``except``. [...]

'raise' and 'except' *are* asymmetrical; instances are raised, but
they are caught by class. As the PEP says, the current syntactic
symmetry is misleading in general (though, I admit, not especially
so in your code sample).
> [...] If this change goes
> through, I might start doing
>> class Found(Exception):
> pass
> Found = Found()

That you think this would work supports my claim that the present
syntax is misleading. <wink>
-- 
Steven Taschuk staschuk@telusplanet.net
Every public frenzy produces legislation purporting to address it.
 (Kinsley's Law)

AltStyle によって変換されたページ (->オリジナル) /