Do Nested try: ... except: 's work?

jestes39 at jestes39 at
Fri Jun 15 15:10:38 EDT 2001

I am trying to use the try: ... except: structure as it is used in 
Oracle for flow control. I am nesting try/except blocks and raising 
named excepts. Each time it gets to a raise statement that is 
referencing an except outside the current block, it fails and gives 
me an error similar to 'there is no variable named <except name>'.
Here is a short section to illustrate my point:

  import telnetlib

          tn = telnetlib.Telnet('')
          no_connect_flag = 'TRUE'

      if no_connect_flag == 'TRUE':
          raise no_connect

          print 'couldn''t set the debug level'
  except no_connect:
      print 'couldn''t open telnet connection'

When I run this script through the debugger, I get the error:
  NameError: There is no variable named 'no_connect'

Any help would be appreciated. Thanks.

jestes3 at

More information about the Python-list mailing list