[Python-Dev] PEP 310 and exceptions

Josiah Carlson jcarlson at uci.edu
Sat Apr 23 04:03:20 CEST 2005


hpk at trillke.net (holger krekel) wrote:
> basically translates to: 
> 
>     if hasattr(x, '__enter__'): 
>         x.__enter__() 
>     try: 
>         ... 
>     except: 
>         if hasattr(x, '__except__'): x.__except__(...) 
>         else: x.__exit__()
>     else: 
>         x.__exit__()

Nope...

>>> def foo():
...     try:
...         print 1
...         return
...     except:
...         print 2
...     else:
...         print 3
...
>>> foo()
1
>>> 

 - Josiah



More information about the Python-Dev mailing list