Method Call in Exception

bwaha cfriedl at bigpond.net.au
Thu Apr 20 07:04:58 EDT 2006


"mwt" <michaeltaft at gmail.com> wrote in message
news:1145490879.789439.18030 at t31g2000cwb.googlegroups.com...
> In my latest attempt at some Python code, I've been tempted to write
> something in the form of:
>
> try:
>     [...] #doing some internet stuff
> except IOError:
>     alternate_method_that_doesnt_need_internet()
>
I'm only a hack at programming but where I find try: blocks useful is where
I have multiple statements within the try: block, any one or more of which
can produce an exception. I just want to trap a failure and get out of
there. This happens to me for any number of reasons when I drive other apps
through the com interface. (In my job I just write simple apps to make my
job easier, not bomb-proof customer-focused code). So in your case perhaps
you have open connection, find site, get data within the try block, and exit
gracefully if any one fails. How you use it depends on what level of detail
you need.

bwaha






More information about the Python-list mailing list