Frequently Asked Questions

How do I exit gracefully from a Python script?

Follow this pattern:

try:
    print 'A'
    sys.exit()
    print 'B'
except SystemExit:
    sys.stdout.flush()

In this example, 'A" is printed, but 'B' is not

How do I manage exceptions or errors ?

Follow this pattern:

try:
    print 'A'
    raise RuntimeError('Please open a window')
except RuntimeError as err:
    DialogDisplayer().showMessageDialog(str(err))
except SystemExit:
    sys.stdout.flush()

You can define your own exceptions or reuse built-in exceptions.

How do I reference my own classes library?

See Creating your own classes library

How do I control garbage collection?

See How to write safe Python scripts

Frequently Asked Questions

Is it possible to use C-Python libraries such as Enthought with INTViewer's Python engine ?

JPython and C-based Python libraries are not natively compatible. However, it is possible to bridge Jython and C-Python.