A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/327150.html below:

are variables local to try/except blocks ?

are variables local to try/except blocks ? are variables local to try/except blocks ?b_c_searle b_c_searle at yahoo.com
Mon Sep 19 10:34:32 EDT 2005
# Is this valid (or is excp local only to try/except)?
 try:
    try:
       doSomething1
       excp = 0
    except:
       excp = 1
    #endTry
    if (_excp_): doSomething1 # is excp defined here?
    excp = 0
 except:
    excp = 1
#endTry
if (excp): doSomething2 # is excp defined here?


 # valid, but more verbose (and maybe redundant?)
 excp = 0
 try:
    excp = 0
    try:
       doSomething1
       excp = 0  # reset incase future inner block
    except:
       excp = 1
    #endTry
    if (_excp_): doSomething1
    excp = 0  # reset incase inner block set excp=1
 except:
    excp = 1
#endTry
if (excp): doSomething2

I am not so interested in what a particular version of the
Python/Jython interpreter does, but rather what is "right".

Pls "CC" replies to searle at ca.ibm.com (as well as newsgroup)
Barry Searle,    searle at ca.ibm.com





More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4