are variables local only to try/except blocks?

Dan dan at cellectivity.com
Tue Sep 20 10:52:44 EDT 2005


> try:
>    try:
>       doSomething1
>       excp = 0
>    except:
>       excp = 1
>    #endTry

Note that you can use "else" after "except" for precisely this purpose:

try:
   foo()
except:
   print 'Exception raised'
else:
   print 'No exception raised'

-- 
   Optimism is the faith that leads to achievement; nothing can be
   done without hope.
        - Helen Keller





More information about the Python-list mailing list