[Python-Dev] Merging PEP 310 and PEP 340-redux?

Phillip J. Eby pje at telecommunity.com
Wed May 11 20:53:30 CEST 2005


At 12:44 PM 5/11/2005 -0600, Shane Hathaway wrote:
>Phillip J. Eby wrote:
> > FYI, there are still use cases for clearing the exception state in an
> > __exit__ method, that might justify allowing a true return from 
> __exit__ to
> > suppress the error.  e.g.:
>
>Maybe __exit__ could suppress exceptions using a new idiom:
>
>          def __exit__(self,*exc):
>              if exc and not last and issubclass(exc[0],self.type):
>                  # suppress the exception
>                  raise None
>
>This seems clearer than "return True".

Nice, although perhaps a little too cute.  But it's moot as Guido has 
vetoed the whole idea.



More information about the Python-Dev mailing list