More Pythonic?

Fredrik Lundh fredrik at pythonware.com
Tue Sep 14 01:41:14 EDT 1999


Aahz Maruch <aahz at netcom.com> wrote:
> Of course, I could do something like
> 
>     try :
>         page = httpWrapper()
>         page.open ( url )
>     except IOError :
>         print page.info()

provided the exception can only happen in the
open method, how about:

    page = httpWrapper()
    try:
        page.open(url)
    except IOError:
        print page.info()
    else:
        # ...proceed...

> but I could also do something like

no, you can't ;-)

</F>





More information about the Python-list mailing list