NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

trace print in JYTHON?

I looked up the jython code to print out the trace when an exception
occurs

This exception .py will not evec "compile"

Any suggestions would be helpful.
Thanks

copy from example:
http://www.python.org/doc/2.1/lib/traceback-example.html

import sys, traceback        # not acceptible

     def run_user_code(envdir):
         source = raw_input(">>> ")
         try:
             exec source in envdir
         except:
             print "Exception in user code:"
             print '-'*60
             traceback.print_exc(file=sys.stdout)
             print '-'*60

     envdir = {}
     while 1:
         run_user_code(envdir)

also tried:

from sys import traceback
def run_user_code(envdir):
 source = raw_input(">>> ")
 try:
  exec source in envdir
 except:
  print "Exception in user code:"
  print '-'*60
  traceback.print_exc(file=sys.stdout)    # not found
  print '-'*60

envdir = {}
while 1:
   run_user_code(envdir)

G. Garrett Campbell Ph. D.
Cooperative Institute for Research in the Atmosphere
Colorado State University
Ft. Collins, CO, USA
970 491 8497
campbell@xxxxxxxxxxxxxxxxxx 


  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: